can I pass variable (variable named test in this case) to jQuery .load function?
$(document).ready(function() {
$('a').clic开发者_如何学JAVAk(function(e) {
e.preventDefault();
var test= $(this).attr('href');
$('.window').load($(test));
});
This doesn't work.
You are wrapping your url in a call to jQuery. Just pass test
, not $(test)
.
$(document).ready(function() {
$('a').click(function(e) {
e.preventDefault();
var test= $(this).attr('href');
$('.window').load(test);
});
});
Also, you are missing the closing });
in your sample code. Not sure if it's a typo here or in your actual code.
In your code, test
is a string. .load
should take that string, not a jQuery object.
$('.window').load(test);
ought to work.
精彩评论