У меня есть сценарий, по которому содержимое div изменяется, когда пользователь нажимает на ссылку.Как добавить контент по умолчанию для div
Но есть проблема. По умолчанию контейнер div пуст. Можно ли сохранить содержание планирования как по умолчанию при загрузке сайта?
Благодаря
document.getElementsByClassName("p1")[0].onclick = function(){
$('.how-text').html($('.planning').html());
};
document.getElementsByClassName("p2")[0].onclick = function(){
$('.how-text').html($('.results').html());
};
document.getElementsByClassName("p3")[0].onclick = function(){
$('.how-text').html($('.improvements').html());
};
document.getElementsByClassName("p4")[0].onclick = function(){
$('.how-text').html($('.communication').html());
};
.st { display:none; }
.how-text { min-height: 300px;
\t height: auto;
\t background-color: #e6ebe4;
\t padding: 20px;
\t margin: 25px 0px 10px 0px;
\t border-radius: 3px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-sm-6">
\t \t <div class="row" style="width: 75%;margin: 0 auto;">
\t \t \t <div class="col-xs-6">
\t \t \t <a href="#" id="one" class='p1'><span id="image1"><b>Planning</b></span></a>
\t \t \t </div>
\t \t \t <div class="col-xs-6">
\t \t \t <a href="#" class="p2"><span id="image2"><b>Results</b></span></a>
\t \t \t </div>
\t \t </div><br>
\t \t <div class="row" style="width: 75%;margin: 0 auto;">
\t \t \t <div class="col-xs-6">
\t \t \t <a href="#" class="p3"><span id="image3"><b>Improvements</b></span></a>
\t \t \t </div>
\t \t \t <div class="col-xs-6">
\t \t \t <a href="#" class="p4"><span id="image4"><b>Communication</b></span></a>
\t \t \t </div>
\t \t </div>
<div class="st">
<div class="planning">
<h3>Planning</h3> \t \t \t
\t \t \t <p class="why-text">Search Marketing Group is a leader in creating unique Seo strategies that would help your website rank on page 1 of
\t \t \t Google for your most competitive keywords in your niche. We pride ourself on creating custom solutions for businesses and
\t \t \t making it work for them. </p> \t
</div> \t
\t \t \t
\t \t \t <div class="results">
<h3>Results</h3> \t \t \t
\t \t \t <p class="why-text">Search Marketing Group is a leader in creating unique Seo strategies that would help your website rank on page 1 of
\t \t \t Google for your most competitive keywords in your niche. We pride ourself on creating custom solutions for businesses and
\t \t \t making it work for them. </p> \t
</div>
\t \t \t
\t \t \t <div class="improvements">
<h3>Improvements</h3> \t \t \t
\t \t \t <p class="why-text">Search Marketing Group is a leader in creating unique Seo strategies that would help your website rank on page 1 of
\t \t \t Google for your most competitive keywords in your niche. We pride ourself on creating custom solutions for businesses and
\t \t \t making it work for them. </p> \t
</div>
<div class="communication">
<h3>Communication</h3> \t \t \t
\t \t \t <p class="why-text">Search Marketing Group is a leader in creating unique Seo strategies that would help your website rank on page 1 of
\t \t \t Google for your most competitive keywords in your niche. We pride ourself on creating custom solutions for businesses and
\t \t \t making it work for them. </p> \t
</div> \t \t \t \t
\t \t </div>
<div class="col-sm-6 how-text">
</div>
не работает на Сайте .. может быть какой-то вопрос –
вы назвали библиотеку JQuery дважды просто удалить один! – Sathish
Можете ли вы назвать jquery? –