user2501504
user2501504

Reputation: 311

JQuery onclick execute event of input field

I don´t know if it´s possible do this , in this case i want when click over input text field activate function in jQuery and after of this action execute the code of jQuery - inside onclick - , i put my example :

<input type="password" name="password" value="" class="input_text_register" id="pass" onclick="jQuery("#list").show();"/>

I can´t do this works , i supose i have some error because no get works finally , in this case the activation from input text field open other div for show informations

Thank´s , Regards !

Upvotes: 1

Views: 25999

Answers (4)

Praveen
Praveen

Reputation: 56539

Have you included jQuery library?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

Better give it as explicit.

<input type="password" name="password" value="" class="input_text_register" id="pass" onclick="clickIt();"/>
<script">
     function clickIt() {
         jQuery("#list").show();
     }
</script>

Upvotes: 1

Rob Schmuecker
Rob Schmuecker

Reputation: 8954

Either try escaping your quotes like this:

<input type="password" name="password" value="" class="input_text_register" id="pass" onclick="jQuery(\"#list\").show();"/>

or change them

<input type="password" name="password" value="" class="input_text_register" id="pass" onclick="jQuery('#list').show();"/>

Upvotes: 0

$('#pass').click(function () {
    $("#list").show();
});

or

change onclick="jQuery("#list").show();"

to

onclick="jQuery('#list').show();"

Upvotes: 2

GautamD31
GautamD31

Reputation: 28773

Try like

<input type="password" name="password" value="" class="input_text_register" id="pass" onclick="myfun();"/>

<script type="text/javascript">
     function my_fun() {
         jQuery("#list").show();
     }
</script>

Or you can also do like

<input type="password" name="password" value="" class="input_text_register" id="pass"/>

<script type="text/javascript">
     $(document).ready(function(){
         $('#pass').on('click',function(){
             jQuery("#list").show(); 
         });
     });
</script>

Or even simply you can try like

<input type="password" name="password" value="" class="input_text_register" id="pass" 
onclick="jQuery('#list').show();"/>

Upvotes: 3

Related Questions