javascript - Button listener to create incremented title -


i'm creating form website let users add step step tutorials. each time user clicks on 'add step' , new block image field , text field appears.

i'm beginning jquery , wanted have title displayed before every new block appearing after user's click 'step 1' ... 'step n'

i tried adding html field block , filling (263 id of 'add step' button , 323 of htlm field added):

$x = 0 $([263]).click(function () { $x ++ ; $("[323]").val("step $x"); } 

but doesn't work ... me please ?

thanks :)

use id selector jquery #... , missing close ); click function. , .text() used set h1 title:

var x = 0 $("#323").text("step " + x); $("#263").click(function() {     x++ ;     $("#323").text("step " + x); }); 

and don't use $x looks php world :)

you can fiddle around code here http://jsfiddle.net/uh8m2wax/

you can place code @ end of page prior body tag this:

<script type='text/javascript'>//<![cdata[  $( document ).ready(function() {      var x = 0      $("#323").val("");      $("#263").click(function() {         x++;         $("#323").val("step " + x);      }); });//]]>  </script> </body> 

edit: changed .text()to .val() since input box used display


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -