A
A
Askfortrue2019-02-13 12:11:42
AJAX
Askfortrue, 2019-02-13 12:11:42

How to make one tab open by default in Ajax?

Hello!
Tell me how to make one tab open by default on ajax?
I have the following code to switch tabs:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript">

$(document).ready(function(){ 
    $('.url_1').click(function(){
        var url=$('.url_1').attr('href');
    $('#content').load(url);
});
});
$(document).ready(function(){ 
    $('.url_2').click(function(){
        var url=$('.url_2').attr('href');
    $('#content').load(url);
});
});
$(document).ready(function(){ 
    $('.url_3').click(function(){
        var url=$('.url_3').attr('href');
    $('#content').load(url);
});
});
$(document).ready(function(){ 
    $('.url_4').click(function(){
        var url=$('.url_4').attr('href');
    $('#content').load(url);
});
});

</script>

And the HTML code where adding "active" does nothing but the appearance of the active tab.
<a type="button" href="/1/11.php" class="url_1 btn btn-ft active" onclick="return false;">Первый</a>
  <a type="button" href="/1/22.php" class="url_2 btn btn-ft" onclick="return false;">Второй</a>
  <a type="button" href="/1/33.php" class="url_3 btn btn-ft" onclick="return false;">Третий</a>
  <a type="button" href="/1/44.php" class="url_4 btn btn-ft" onclick="return false;">Четвр</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2019-02-13
@Askfortrue

What a horror...
For ten tabs, you would probably make ten copies, but for a hundred tabs?

$(document).ready(function() { 
  $('.url').click(function() {
    $('#content').load($(this).attr('href'));
  });
  $('#content').load($('#url_1').attr('href'));
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question