Search code examples
jqueryfindjquery-selectors

Get Next Element with Name Containing


Ok, I have been fighting with this for over an hour so I have to ask. Here is my HTML

<a id="edit_shipping">[ Save ]</a>
<span>Method: <input id="new_shipping_method" type="text" value="Free Shipping"></span>
<input type="hidden" name="order_total[1][order_total_id]" value="14">

And my jquery

$("#edit_shipping").on("click",function(){
   alert($(this).next('input[name*="order_total_id"]').val());
});

I can not for the life of me figure out why I keep getting an undefined. I also tried the find selector and the same results. Please help!


Solution

  • Can you tell me if it works ?

    $("#edit_shipping").on("click",function(){
       alert($(this).siblings('input[name*="order_total_id"]').val());
    });