I'm trying to load a css file as needed. I'm looking for the #slider as my trigger. If it exists, then load this style sheet.
I've tried both methods below and neither work. Am I missing something somewhere?
Code:
<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() {
if ( $("#slider").length > 0) {
$('<link>').appendTo('head').attr({
rel: "stylesheet",
type: "text/css",
href: "/css/controls10.css"
});
}
});
</script>-->
<script type="text/javascript">
$(document).ready( function() {
if ( $("#slider")) {
$("link[rel=stylesheet]").attr({href : "css/controls10.css"});
}
});
Also is there a way to cache the plugin call? I read .getScript doesn't cache so I tried .ajax.
Code:
$.ajax({
type: 'GET',
url: 'xxx',
cache: true,
success: function() {$("#slider").easySlider({
auto: true,
continuous: true,
numeric: true,
numericId: 'controls',
speed: 800,
pause: 6000
}); },
dataType: 'script',
data: null
});
I only want to make the function call and not use a url. (Since there is no file needed to run this.)
Any help is appreciated