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

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -