Conflict between jquery and bootstrap

I have code where I include jquery files and bootstrap files in header.php. I run into problems when if I include the jquery file before the bootstrap.js file, it will interfere with other tabs on my web page, and basically, even if I click on other tabs, they will not move me.

I think there is a conflict between jquery and bootstrap. I am inserting a header.php file below for further reference.

header.php

<?php require_once "essentials.php";
//error_reporting(~0);
//ini_set('display_errors', 1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--<style>{height:150px; width:1300px;}</style>-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="Public">
<title><?php echo $page_title?></title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script src="script_dbafactory.js?<?php echo rand(0,511);?>"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<!--<link href="css/style_header.css" rel="stylesheet">-->
</head>
<body>
<div class="container">
        <div class="row clearfix">
                <div class="col-md-4 column">
                        <img alt="logo" src="./images/source.png">
                </div>
                <div class="col-md-8 column dbf">
                        <h2>
                                DBA Factory
                        </h2>
                </div>
        </div>
        <div class="row clearfix">
                <div class="col-md-12 column">
                        <div class="tabbable" id="tabs-775712">
                                <ul class="nav nav-tabs">
                                         <li>
                                                <a href="../dbafactory/home_page.php?sub=1" data-toggle="tab">Home</a>
                                        </li>
                                        <li>
                                                <a href="../dbafactory/form_page.php?sub=2" data-toggle="tab">Submit a project</a>
                                        </li>
                                        <li>
                                                <a href="../dbafactory/view_table.php?sub=3" data-toggle="tab">All Projects</a>
                                        </li>
                                        <li>
                                                <a href="#panel-4" data-toggle="tab">Innovative Ideas</a>
                                        </li>
                                        <li>
                                                <a href="#panel-5" data-toggle="tab">Matchmaker</a>
                                        </li>
                                        <li>
          <a href="#panel-6" data-toggle="tab">Meet the Team</a>
                                        </li>

                                        <div class="dropdown">
                                        <?php include "userlogin.php"; ?>
                                        </div>
                                </ul>

                        </div>
                </div>
        </div>


</div>
</body>

<!--<script type="text/javascript">
//Script to implement tabs 
$('#myTab a').click(function (e) {
  e.preventDefault()
  $(this).tab('show')
})

</script>-->
<script>
$.noConflict();
$(document).ready(function (){
        $('.dropdown-toggle').dropdown();
        $('#userlogin').dropdown('toggle');
});
</script>

Can someone please let me know how I can solve this problem? and how should I download all js and css files to avoid problems with the webpage.

thanks

+4
source share
2

data-toggle = "tab" bootstrap , [tab panel], nav, .

, : http://getbootstrap.com/javascript/#tabs

, js- js:

(function($){
    ....
})(jQuery);

, , WinMerge :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--<style>{height:150px; width:1300px;}</style>-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="Public">
<title><?php echo $page_title ?></title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
<!--<link href="css/style_header.css" rel="stylesheet">-->
</head>
<body>
<div class="container">
        <div class="row clearfix">
                <div class="col-md-4 column">
                </div>
                <div class="col-md-8 column dbf">
                        <h2>
                                DBA Factory
                        </h2>
                </div>
        </div>
        <div class="row clearfix">
                <div class="col-md-12 column">
                        <div class="tabbable" id="tabs-775712">
                                <ul class="nav nav-tabs">
                                         <li>
                                                <a href="#panel-4">Home</a>
                                        </li>
                                        <li>
                                                <a href="#panel-4">Submit a project</a>
                                        </li>
                                        <li>
                                                <a href="#panel-4">All Projects</a>
                                        </li>
                                        <li>
                                                <a href="#panel-4">Innovative Ideas</a>
                                        </li>
                                        <li>
                                                <a href="#panel-5">Matchmaker</a>
                                        </li>
                                        <li>
                                                <a href="#panel-6">Meet the Team</a>
                                        </li>

                                        <li class="dropdown">
                                            <a id="userlogin" role="button" data-toggle="dropdown" href="#">rdesai<span class="caret"</span></a>

                                            <ul class="dropdown-menu" role="menu" aria-labelledby="userlogin">
                                                <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Settings</a></li>
                                            </ul>
                                        </li>
                                </ul>

                        </div>
                </div>
        </div>


</div>
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script>
(function($){

    $(document).ready(function (){
            $('.dropdown-toggle').dropdown();
            $('#userlogin').dropdown('toggle');
    });

})(jQuery);
</script>
</body>
</html>
+4

, jquery bootstrap, php :

<script>jQuery.noConflict();</script>

.

: https://api.jquery.com/jQuery.noConflict/

Edit:

<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.min.js" type="text/javascript"></script>

1.10.3

+3

Source: https://habr.com/ru/post/1525538/


All Articles