Skip to content Skip to sidebar Skip to footer

Get Input Value Using Htmlfor

What’s the best way to accomplish something like this: html.erb &

Solution 1:

You can use jQuery attribute selector and next() method to do this like following.

$("[data-id=wish]").click(function(e){
    e.preventDefault();

    var value = $(this).next(".wish-cls").val();
    console.log("Clicked: " + value);
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><idata-id="wish">Click</i><inputtype="hidden"class="wish-cls"name="wish"value="1000" />

Post a Comment for "Get Input Value Using Htmlfor"