2

How can I change the contents of my paragraph as well as the contents of my list once the link was clicked. reference: http://dummyproto.atspace.co.uk/

once i click woven badges on the navigation carousel i want to change the contents of the p as well as the imaged displayed. Is that possible via javascript? Is it a great alternative rather than creating a bunch of html pages for every page which has the same layout but different contents.

I'm looking forward to detailed solutions.Thanks

1

3 Answers 3

3

You need to modify your HTML a bit first so the content you want to swap out is contained in a single element that is easily selectable (for example wrap a div with a unique class name or id around just the stuff you want to swap out). Then do something like this:

document.getElementById('whateverIdYouGaveTheDiv').innerHTML = "blah blah blah";
Sign up to request clarification or add additional context in comments.

3 Comments

thats fine with p element but how can i execute that if i would change this <li><a class="zoomThumbActive" href='javascript:void(0);' rel="{gallery: 'gal1', smallimage: 'UniwinView.jpg',largeimage: 'Uniwin.jpg'}"><img src='uniwinThumb.jpg'></a></li> I have to change the small image,largeimage and the img.
I guess you would put it in a function and then call that function instead of doing nothing where you have javascript:void(0); ... although generally I think using the javascript: URI scheme is considered bad form...
ah.well i just got that from a jqzoom plugin. i just keep tweaking them. do you know how can i do the function for it?
2

maybe you can try jQuery template.

or, change the html when the trigger is clicked by using .click() and .html()

like:

var target_html = "something you want";

$('#trigger').click(function() {
    $("#content").html(target_html);
});

2 Comments

i think doing that will just be the same as linking the page and still i have to create a bunch of html pages. isnt it?
I just checked your site, i think, query template is perfect to you. you can write all your content into a JSON object, and render them by the template engine.
0

Personally, I'd make a div "card" for each of your carousel options containing any images or text you want to go with them. Then I'd set all of them but the first to display: none;. When another link in the carousel is clicked, I'd cycle through the "cards," setting them all to display: none except the one needed (which should have the same number in the order of cards as the carousel item you selected in the order of carousel items), which will be display: block; so that I don't have to store HTML into Javascript variables.

1 Comment

thanks. I think this is the simplest solution and still works out perfectly. i'll be sticking to div styling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.