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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -