Answer the question
In order to leave comments, you need to log in
How to implement dynamic content correctly?
Hi guys, I need your help)
Tell me how to properly organize dynamic content on the old man depending on the url, for example, if a person clicked on the link https://jsfiddle.net/javascript
Then replace the page title, description, h1 tag, a couple of words on the page #word1, #word2 and in the img tag replace src, alt, title?
For example, here is a code sketch:
document.title = NewTitle;//header title
$('meta[name="description"]').attr('content', description); // description
$('#main-title').html(mainTitle); //main-title
$('#word1').html(mainTitle); //word1
$('#word2').html(mainTitle); //word2
$( "#greatphoto" ).attr({
alt: photoAlt,
title: photoAlt
});
<header>
<title></title>
<meta name="description" content=""/>
</header>
<body>
<div class="main-content">
<h1 id="main-title"></h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim <span id="word1"></span>veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint <span id="word2"></span> occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<img id="photo" src="" alt="" title="">
</div>
</body>
Answer the question
In order to leave comments, you need to log in
You can try to do something like collections on jsone. And when, for example, you determine which url, you pull the data through the collection.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question