JQuery - change attribute of asp object
How can I use jquery to set Chart1 to be 开发者_StackOverflowvisble? The following code is what im trying but its fail. Please help, thanks a lot
<script type="text/javascript">
function helloWorld() {
$(document).ready(function () {
$('#Chart1').attr("Visible", "true");
})
}
</script>
<asp:Chart ID="Chart1" runat="server" Width="860px" Visible="false" onmouseover="helloWorld();" >
By having the server side property Visible
set to false, you're causing it to never be sent to the browser, client side code will be helpless.
First, change Visible="false"
to: style="display: none;"
then such code should work, assuming the final ID of the element will indeed be Chart1
:
$(document).ready(function () {
$('#Chart1').show();
})
If no luck, check the HTML source code to know the actual ID and let me know, you'll have to use some sort of pattern lookup.
The problem is almost certainly that the ID is being uniquified by the ASP control, and so is no longer simply Chart1. There is also the likelihood that the control produces a set of html. So I would suggest you identify what the html being generated is, and write your javascript against these objects.
精彩评论