Jump to content

Any good source for jQuery Q&A?


george

Recommended Posts

This works as intended in IE, but not in FF

	<script type="text/javascript">		$(document).ready(function(){			/* give all divs with an id attribute a clear border */			$("div[id]").css("border","1px, solid black");		})	</script>

How come? And is there a discrepencies list anywhere?

Link to comment
Share on other sites

This works as intended in IE, but not in FF
	<script type="text/javascript">		$(document).ready(function(){			/* give all divs with an id attribute a clear border */			$("div[id]").css("border","1px, solid black");		})	</script>

How come? And is there a discrepencies list anywhere?

this is what I would try
	<script type="text/javascript">  $(document).ready(function(){	/* give all divs with an id attribute a clear border */	$("div").each(function(){	  if(this.id){		this.css("border","1px solid black");	  };	});  });</script>

http://api.jquery.com/each/

Link to comment
Share on other sites

No. The intended outcome did not occurr in either browser. I'll just switch back to the one that worked in IE, since this is just an excersize to correct the css I have for a site. But the bigger question looms, why does this work in IE and not FF? I thought jQuery was supposed to be cross browser. It is also supposed to be assessable, but not by sans-mouse navagation it is not.

Link to comment
Share on other sites

it appears I meant to say border, not border style. Are there any errors on the page at all when you view it?can you post the relevant HTML, or post a link, so we can try it with the same code you are?

Link to comment
Share on other sites

damn. good call on the .attr. that's probably it.
your code would have worked, if it was not using the js method instead of jq, to change styling (and border-style error, of course) $(document).ready(function(){ /* give all divs with an id attribute a clear border */ $("div").each(function(){ if(this.id){ $(this).css("border","1px solid black"); }; }); });
Link to comment
Share on other sites

thats easy, get id attribute name and assign it to title attribute of div

 $(document).ready(function(){	/* give all divs with an id attribute a clear border */   $("div").each(function(){	if($(this).attr("id")){	$(this).css("border","1px solid black");	var idname = $(this).attr("id")	$(this).attr("title", idname)	 };	});  });

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...