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". Commented Sep 7, 2017 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']") Commented Sep 7, 2017 at 16:51

1 Answer 1

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? Commented Sep 7, 2017 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(); Commented Sep 7, 2017 at 17:01

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.