Reputation: 2520
I have a simple request(still learning javascript). I have a title div and 3 divs(with an anchor tag inside each) below it. Basically what I want, is when you click on one of the anchor tags, that that specific anchor tag should hide(actually its parent div), and the text in the Title div above should change. How can I do that? See overly simplified example.
Upvotes: 0
Views: 359
Reputation: 6996
Not sure as to this is what you are looking for Check demo.
You are mixing javascript with jquery. You can hide a element by something like this
$(this).hide();
Upvotes: 1
Reputation: 11132
You're mixing jQuery DOM access and plain DOM access, which will cause some problems. Use the $('#id')
selector instead of document.getElementById('blah');
To make a div disappear on click:
$('#mydiv').click(
function()
{
$(this).hide();
$('#otherdiv').html('new html');
}
);
Upvotes: 1
Reputation: 47677
Try this - http://jsfiddle.net/gGAW5/54/
$(document).ready(function() {
$("a").click(function() {
$("#myTitle").html( $(this).html() );
$(this).hide();
});
});
Upvotes: 1