Separate JQuerys and Css

0

I have a index.php that uses the following JQuery and CSS :

<script src="http://code.jquery.com/jquery-1.12.1.min.js"></script><scriptsrc="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

And from this index , I call a second page example.php through a normal link without passing forms or anything and using another JQuery and CSS :

<script src="http://code.jquery.com/jquery-1.12.1.min.js"></script><scriptsrc="http://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<link href="http://code.jquery.com/ui/1.11.4/themes/dark-hive/jquery-ui.css" rel="stylesheet">

My question is:

The JQuery and CSS of index is affecting and overwriting that of example.php page.

How can I fix this?

    
asked by anonymous 10.03.2016 / 14:24

1 answer

0

Hi, Diego Lucas! Blz?

Is example.php being called within content index.php ? I say this because if example.php is another page, being called in the browser separately from index.php, jQuery and CSS do not have to affect it. >

But ... If you are inserting new scripts in index.php through a call from the example.php page, I recommend do not call jQuery again.

Take a look at this William Bruno post that talks a little about script conflicts: link

If pages are called separately, include the scripts and styles you want. They should be loaded normally and without any link with index.php.

Abs.

Complementing

Since the pages are linked, you can identify the tags to manipulate them.

<script src="http://code.jquery.com/jquery-1.12.1.min.js"></script><scriptid="jqMobileJs" src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script><linkid="jqMobileCss" rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">

And in the example.php page

<script>
var novoJs = "http://code.jquery.com/ui/1.11.4/jquery-ui.min.js";
var novoCss = "http://code.jquery.com/ui/1.11.4/themes/dark-hive/jquery-ui.css";
$('#jqMobileJs').attr('src', novoJs);
$('#jqMobileCss').attr('href', novoCss);
</script>

Note: I think you'd better identify where the index.php files are coming from and to separate it from example.php . Anyway, I left this code here, so you can test.

    
10.03.2016 / 15:24