jQuery PrevAll() selector fail -
jQuery PrevAll() selector fail -
i'm trying grab , display value of input when button clicked.
class="snippet-code-js lang-js prettyprint-override">$('.nextbtn').click(function() { alert($('this').prevall('input[type=tel]').val()) })
class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="step" id="step1"> <h2>how old you?</h2> answer: <input type="tel" /> years old <button id="stepbtn1" class="nextbtn">next</button> </div>
demo here: http://jsfiddle.net/r7c1skgg/11/
there's fundamental i'm not understanding here i'm sure, prevall doc doesn't seem spell reply (i'm sure it's obvious).
try , alter solution without define id. problem quote in $(this).prevall not $('this')
class="snippet-code-js lang-js prettyprint-override"> $('.nextbtn').click(function() { alert($(this).prevall('input[type=tel]').val()); })
class="snippet-code-html lang-html prettyprint-override"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="step" id="step1"> <h2>how old you?</h2> answer: <input type="tel"/> years old <button id="stepbtn1" class="nextbtn">next</button> </div>
jquery
Comments
Post a Comment