<script type="text/javascript" language="javascript" src='<%= ResolveClientUrl("~/Scripts/jquery-1.7.2.js") %>' ></script> and check if you encounter the same issue. looks like your jQuery script is not being loaded in this particular senario
Marked as answer by JAYHAWKER on Aug 03, 2012 10:03 PM
I tried it, and I get the same error. I use JQuery all over the place and never get the error, but I have never had a function start with $. I have variables start with $ all the time, but not functions. It is new to me.
You can either use jQuery or $ for the function.. that should not be a problem..
Ok first after you load the page hit the F12 button in chrome or Firefox and then check the sources tab of the Developer tools and then make sure that the jQuery file is loaded first.. If you can see this file in the window then jQuery was successfully
added, otherwise you need to place the path to the file in the Head section of your aspx page..
After you do this write this piece of code..
$(function () {
alert('Hello World');
});
You should see this message as soon as page is ready which signifies that the DOM is available to be manipulated and jQuery library is loaded.. Then replace the alert with your code.
JAYHAWKER
Participant
1252 Points
1896 Posts
Can't get css property to change with javascript, any ideas?
Jul 30, 2012 10:40 AM|LINK
I have a css file named LView.css
in LView.css I have a class
.displayDimension
{
display: none;
}
I have a function to change the display: none; to display: block;
function changeRule(selector, property, setting) { theRule = LView.cssRules ? LView.cssRules[findCSSRule(selector)] : LView.rules[findCSSRule(selector)]; eval('theRule.style.' + property + '="' + setting + '"'); return false; }I have a hyperlink that calls the changeRule function:
<a href="#" onclick="changeRule('.displayDimension', 'display', 'block'); return false;" title="changeRule('.displayDimension', 'display', 'block');">Show/Hide</a>I get an error stating: LView is undefined?
What am I doing wrong?
prabu.raveen...
Contributor
5020 Points
955 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 30, 2012 10:57 AM|LINK
Note: index 0 may varry based on your application.JAYHAWKER
Participant
1252 Points
1896 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 30, 2012 01:58 PM|LINK
Now I get an error:
findCSSRule is undefined
sushanth009
Contributor
6243 Points
1168 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 30, 2012 03:48 PM|LINK
You have a much simpler way of doing this .. I have provided an example http://jsfiddle.net/sushanth009/8V6Pw/
Let me know if this is what you are looking for.
JAYHAWKER
Participant
1252 Points
1896 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 30, 2012 04:01 PM|LINK
I get an error, $ is undefined tryin to use it. I like the concept though!
sushanth009
Contributor
6243 Points
1168 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 30, 2012 04:08 PM|LINK
$ is part of the jQuery library based on javascript..
You need to include the jQuery script file to make it work..
Include <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script>
in the head section of your master page or the .aspx page for whcih you want this functionality,,
JAYHAWKER
Participant
1252 Points
1896 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 31, 2012 12:32 PM|LINK
I assume that the following code just goes between the script tags like this:
<script type="text/javascript" language="javascript" src='<%= ResolveClientUrl("~/Scripts/jquery-1.7.2.js") %>' ></script>
<script type="text/javascript" language="javascript">
$(function () { $('a').on('click', function () { $('a').toggleClass('displayDimension'); }); $('#btn').on('click', function () { if ($('a').hasClass('displayDimension')) $('a').removeClass('displayDimension'); }); });sushanth009
Contributor
6243 Points
1168 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 31, 2012 03:34 PM|LINK
Try including this line
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script>
Insteasd of
<script type="text/javascript" language="javascript" src='<%= ResolveClientUrl("~/Scripts/jquery-1.7.2.js") %>' ></script> and check if you encounter the same issue. looks like your jQuery script is not being loaded in this particular senario
JAYHAWKER
Participant
1252 Points
1896 Posts
Re: Can't get css property to change with javascript, any ideas?
Jul 31, 2012 03:39 PM|LINK
I tried it, and I get the same error. I use JQuery all over the place and never get the error, but I have never had a function start with $. I have variables start with $ all the time, but not functions. It is new to me.
sushanth009
Contributor
6243 Points
1168 Posts
Re: Can't get css property to change with javascript, any ideas?
Aug 03, 2012 03:10 PM|LINK
You can either use jQuery or $ for the function.. that should not be a problem..
Ok first after you load the page hit the F12 button in chrome or Firefox and then check the sources tab of the Developer tools and then make sure that the jQuery file is loaded first.. If you can see this file in the window then jQuery was successfully added, otherwise you need to place the path to the file in the Head section of your aspx page..
After you do this write this piece of code..
$(function () { alert('Hello World'); });You should see this message as soon as page is ready which signifies that the DOM is available to be manipulated and jQuery library is loaded.. Then replace the alert with your code.