Reputation: 1176
I have a hidden Input in my web page that it contains another Input control's Id. now how can access to the specific Input controls that it's id is in my hidden input value whit JQuery?
<input type="hidden" id="edBuyMeal" runat="server" value="BtnId" enableviewstate="False" />
function SetBuyAttr(s) {debugger
var Attr = s.split('^');
var btn ="'#'" +$("#" + $("#edBuyMeal").val());
$(btn).css("color","red");
}
I'm beginner in Jquery.
Upvotes: 0
Views: 29
Reputation: 15865
In ASP.NET and standard javascript you would find the hidden field like this:
var btn = document.getElementById("<%:edBuyMeal.ClientID%>");
Your code is unclear, but it appears that you are getting the value from the hidden field, the value being the id of a button, then setting the css class of that button.
That would look like this:
var hidden = document.getElementById("<%:edBuyMeal.ClientID%>");
var btnId = hidden.val();
ASP.NET changes the Id's of the elements. Anything with runat="server"
you will need to make sure that ClientIDMode="Static"
is set for BtnId
. This will allow you to add a css class like this:
$(btnId).addClass("myRedClass");
While javascript will be faster, if you want to do it in JQuery it would look like this:
var hidden = $("#<%:edBuyMeal.ClientID%>");
Upvotes: 1