+ Start a Discussion

ids values isn't putting in Text boxes

My code:

<apex:page sidebar="false" showheader="false">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" />
$(document).ready(function() {
$('input[id^="textInput"]').val('news here!');
<apex:inputText id="textInput1"/>
<apex:inputText id="textInput2"/>
<apex:inputText id="textInput3"/>


In above code, on page load,jquery value isn't put in the textboxes.Is any error is in my code? 


To select VF component using jquery you need ENDS WITH selector


Something like


$('[id$="textinput1"]').val('My Value');



Thanks Avi.Still its not working.

In my expected output is 

all input texts with an attribute id that starts with 'textInput ' and puts text('My Value') in them.


But your above code is working only for id that starts with 'textInput1 '.Is it possible to get the above my expected output?


Well salesforce has its own algorithm to generate Ids. It generraly adds a prefix to the Id.

Use style class instead

<apex:inputText id="textInput1" styleclass="myInput"/>
<apex:inputText id="textInput2" styleclass="myInput"/>
<apex:inputText id="textInput3" styleClass="myInput"/>

$('.myInput').val('My Text');