javascript - Retrieve value from input next to a button using THIS selector -
i ran problem, have 2 siblings, input , button calls function retrieve value in input, keeps telling me value undefined...
here's "form":
<li> <input id="mem3" value="testu4" disabled=""> <button id="del3" class="delmem" onclick="deletebandmember();">remove</button> </li>
here's jquery code:
function deletebandmember() { var mmbr = $(this).prev("input").val(); //<-returns undefined }
i need use selector there many dynamically-created inputs... thanks!
pass this
parameter in deletebandmember
function shown :-
html :-
<li> <input id="mem3" value="testu4" disabled=""> <button id="del3" class="delmem" onclick="deletebandmember(this);">remove</button> </li>
jquery :-
function deletebandmember(elem){ var mmbr = $(elem).prev("input").val(); }
Comments
Post a Comment