jquery - How can access the control that we have it's id -


I have a hidden input in my web page in which it has another input control ID, now how to the specific input controls Can I access this code to cache JQuery in my hidden input value?

  & lt; Input type = "hidden" id = "edBuyMeal" runat = "server" value = "btnid" enabled viewstate = "wrong" />   
  function setbuyert (s) {debugger wher etter = es. s. Lit ('^'); Var btn = "'#'" + $ ("#" + $ ("# edBuyMeal"). Val ()); $ (Btn) .css ("color", "red"); }   

I am starting in junkery.

.NET and standard JavaScript in ASP will give you hidden fields like this:

  var btn = document.getElementById ("& lt;%: edBuyMeal.ClientID%>");   

Your code is unclear, but it appears that you are getting a value from the hidden field, the value is the ID of a button, then setting the CSS class of that button.

It will look like this:

  var hidden = document.getElementById ("& lt;%: edBuyMeal.ClientID%>"); Var btnId = hidden.val ();   

ASP.NET Anything with the Elements ID varies runat = "server" will require you to ensure that ClientIDMode = "static" is < Code> BtnId . This will allow you to like it:

  $ (btnId) .addClass ("myRedClass");   

While JavaScript will be fast, if you want to do it in JQuery, it will look like this:

  var hidden = $ ("# & lt ;%: EdBuyMeal.ClientID%> & quot;);    

Comments

Popular posts from this blog

Out of index C/C++ -

regex - PatternSyntaxException: while using String.ReplaceAll function in java? -

objective c - how Set autolayout for multiple dynamic buttons and labells in iOS? -