wordpress - What is wrong with my jQuery code? Gives error that it's not a function -


am using in wordpress, tried change $ sign jquery, did not work too. script:

<script>     jquery().ready(function($) {        var name = $('#user-submitted-posts-wrapper').data('name');        if ( name != '') $('.usp-title input').eq(0).value(name);     });     </script> 

and getting error:

 $(...).eq(...).value not function 

what might problem? trying prefill input field text get. input field has name attribute, no class or id attribute. better use? doing wrong?

because $().value undefined (not function).

the value property belongs htmlinputelement dom interface, jquery objects don't have property or method name.

jquery objects provide .val() method set elements' value property:

$('.usp-title input').eq(0).val(name); 

you may , set dom element properties directly retrieving dom element reference jquery object through .get method:

$('.usp-title input').get(0).value = name; $('.usp-title input')[0].value = name; //shorthand form 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -