Question

This is a basic jQuery question - I'm using the spinbox plugin, here:

http://dev.jtsage.com/jQM-Spinbox/

<div data-role="fieldcontain">
<label for="spin">Input spinner</label>
<input data-role="spinbox" name="spin" id="spin" value="50" min="0" max="100" />
</div>

updated value is shown correctly when clicking + or -,

but using this call...

$(this).replaceWith("<div>"+ $("#spin").val +"</div>" );

..returns garbage (code) and

$(this).replaceWith("<div>"+ $("#spin").value +"</div>" );

..returns "undefined"

I want to replace some element with the value of the spinbox. I'm assuming that the widget should make it this easy. Any help will be appreciated

Thanks in advance

Was it helpful?

Solution

jQuery val() is a method not a property, try the following:

$(this).replaceWith("<div>"+ $("#spin").val() +"</div>" );

if you want to use value property you should convert the jQuery object to a DOM element:

$("#spin")[0].value
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top