1

I want to change input background color and text

HTML

   <input type="button" name="ctl00$ctl40$g_31468fa3_6955_464f_99a3_1a53cb733c3b$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem" value="Guardar" onclick="if (!PreSaveItem()) return false;if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl40$g_31468fa3_6955_464f_99a3_1a53cb733c3b$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))" id="ctl00_ctl40_g_31468fa3_6955_464f_99a3_1a53cb733c3b_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem" accesskey="O" class="ms-ButtonHeightWidth" target="_self">

with jQuery I think is something like:

.parent().css("background-color", "#5858FA")

but I don´t have an idea of how to select field. Regards

2
  • This is not related to SharePoint itself, but rather javascript/jQuery. Here's the answer: stackoverflow.com/questions/10306129/… Please consider searching next time since you can find many answer for this by searching "How to select element by name with javascript". – Marc-André Sep 7 '17 at 16:45
  • I think you are better off selecting a parent container then grabbing the button, but it would be something like $("button[name*='diidIOSaveItem']") – Mike Sep 7 '17 at 16:51
3

Refer this -- https://api.jquery.com/attribute-equals-selector/

You can use selector this way for input button tag as well.

First change the background color as below:

$("input[value='Guardar']").css("background-color", "#5858FA");

then change the value as below:

$("input[value='Guardar']").val("NewBtnValue");
2
  • one more question, to hide button I just use $("input[value='Guardar']").hide? – Ledwing Sep 7 '17 at 16:58
  • @Ledwing You will have to use the present value for selecting the button. In this case if you have already changed the value of your button to NewBtnValue, the you will have to use NewBtnValue in your selector. e.g. $("input[value='NewBtnValue']").hide(); – Rohit Waghela Sep 7 '17 at 17:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.