Help with Jquery

Joined
Aug 4, 2011
Messages
1
Reaction score
0
Hey guys.

I've been looking around the internet, and I figured I'd sign up here and see if you guys can't help.

I'm pretty much new to Jquery, and I was looking for some help with some code.

Code:
$("#button").click(function() {
  $("#container").slideDown("slow");
  $("#button_container").html("<a style='cursor: pointer;' id='cancel'>Cancel</a>");
});

That's the code I'm trying to use, but when I use .html() on

Code:
<a id="button_container"><a style="cursor: pointer;" id="button">Button text</a> – <a style="cursor: pointer;" id="button2">Button 2 text</a></a>

But when I use .html() it's only appending the "cancel" button code. I need it to replace both of the buttons with the "cancel" button.

thanks!
 
ok so why use an <a> tag as a container when <div> makes perfect sense?

before jumping into jquery please learn basic html and html styling.

cause i felt like spoon feeding today:
Code:
<script>
$().ready(function() {
	$('#button_container').html($('<a/>').css({ 'cursor': 'pointer' }).attr('id', 'cancel').html('Cancel'));
});
</script>
<div id="button_container">
	<a style="cursor: pointer;" id="button">Button text</a> – <a style="cursor: pointer;" id="button2">Button 2 text</a>
</div>
 
Last edited:
Back