W
W
westdp2015-12-17 12:08:39
JavaScript
westdp, 2015-12-17 12:08:39

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>


The catch is that, for example, these variables should be, for example, 50 pieces. How can I store variables correctly so that it is as easy as possible to change the desired content depending on the url https://jsfiddle.net/ javascript or https://jsfiddle.net/ angular and so on...
Thanks jsfiddle.net/westdp1991/vanas0cy/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Michael, 2015-12-17
@scherbuk

If I were you, I would store it in a file. in json for example

V
vovastradamus, 2015-12-18
@vovastradamus

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 question

Ask a Question

731 491 924 answers to any question