jQuery - get content of element -- not working in FF

this line is throwing error, ONLY in Firefox…

content = $(this).html();

setting a property that has only a getter…

am trying to GET content of element…

now I thought you could GET an elem’s .html()…
.html() – jQuery API and also acc. to this…
http://stackoverflow.com/questions/5487309/jquery-get-div-content

I need to replace only partial content inside element, how do I do this if I can’t GET the content of it???

thank you…

The obvious question is what is “this”.

In what context are you using the statement?


$('ul.dropdown li.top_level:not(.selected) a').each(function(i) {
	_content = $(this).html();
	content = _content.substring(4,_content.length);
	$(this).html('Link ' + content);
		
});

as mentioned, this works fine in Safari and Chrome… (can’t test on IE)
why on earth won’t it work on FF?? this has never happened to me before…

Is it possible to post a sample of the html involved.

<ul class="dropdown">
	<li class="top_level"><a class="first" href="#">Tab One</a>
		<ul>
			<li><a class="first" href="#">Sublink One</a></li>
			<li><a href="#">Sublink Two</a></li>
			<li><a href="#">Sublink Three</a></li>
		</ul>
	</li>
	<li class="top_level"><a href="#">Tab Two</a>
		<ul>
			<li><a class="first" href="#">Sublink One</a></li>
			<li><a href="#">Sublink Two</a></li>
			<li><a href="#">Sublink Three</a></li>
		</ul>
	</li>
	<li class="selected top_level"><a href="#">Tab Three</a></li>
	
	<li class="top_level"><a href="#">Tab Four</a></li>
	
	<li class="top_level last"><a href="#">Tab Five</a></li>
</ul>

thank you…

OK I don’t understand why

but

putting a var before _content and content seems to resolve the problem.

$('ul.dropdown li.top_level:not(.selected) a').each(function(i) {
	var _content = $(this).html();
	var content = _content.substring(4,_content.length);
	$(this).html('Link ' + content);
		
});

Appears _content is a property of the window object

See _content property (window) JavaScript

So it is just _content that needs to have the var

oh my gosh… I don’t believe it… when in doubt check var names, I guess…

thank you very much…