Thanks Chris. It is solved after apply ID
On Friday, July 25, 2014 3:04 PM, Chris Pratt <thechrispr...@gmail.com> wrote: Make sure you set the "id" attribute on the s:textfield if you're going to refer to it that way using jQuery. (*Chris*) On Fri, Jul 25, 2014 at 12:30 PM, john lee <sh_thorn_b...@yahoo.com.invalid> wrote: > > I can use jquery to change html input tag's placeholder for no problem, > but no matter what method I use, impossible for me to change > s:textfield's placeholder. > I tried > $('#partid').attr('placeholder','XXX'); > and > $('#partid').val('XXX'); > and > $('#partid').text('XXX'); > > s:textfield's placeholder impossible for jquery to change, is struts2 > limition or bugs? > > thanks in advance > > john > > ************************************************************* > > <%@ taglib prefix="s" uri="/struts-tags" %> > <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> > <sj:head jqueryui="true"/> > > <script language="javascript"> > $(document).ready(function() { > $('#searchchoice').change(function() { > var ex = document.getElementById("searchchoice"); > var finalchoice = ex.options[ex.options.selectedIndex].text; > if (finalchoice=='part#') > $('#partid').attr('placeholder','input example: XXX'); > else if (finalchoice=='keyword') > $('#partid').attr('placeholder','input example 2: > XXX'); > else if (finalchoice=='model') > $('#partid').attr('placeholder','input example 3: > XXX'); > > }); > }); > </script> > > <s:form class="nav-search" action="PartsearchbothAction" method="post" > theme="simple" > > <s:select label="Part#" > id="searchchoice" > name="searchchoice" > list="#{'part#':'part#', 'keyword':'keyword', > 'model#':'model'}" > value="part#" > theme="simple" > required="true" > /> > <s:textfield name="partid" label="partid" placeholder='default > search is by Part#' required="true" theme="simple"/> > > <s:submit value="go"> > </s:form>