最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery .get not working - Stack Overflow

programmeradmin1浏览0评论

I have the following code that I run whenever the .information element is clicked. I am trying to add the aboutMe.html document to the #text element when the .information is clicked:

$(".information").click( function() {
    $.get("aboutMe.html"), function(data){
        $("#text").html(data);
}});

For some reason the document is not added to the page when .information is clicked.

I have the following code that I run whenever the .information element is clicked. I am trying to add the aboutMe.html document to the #text element when the .information is clicked:

$(".information").click( function() {
    $.get("aboutMe.html"), function(data){
        $("#text").html(data);
}});

For some reason the document is not added to the page when .information is clicked.

Share Improve this question edited Nov 8, 2016 at 2:11 fragilewindows 1,4121 gold badge16 silver badges26 bronze badges asked May 23, 2014 at 20:07 SjoerdvdBeltSjoerdvdBelt 3001 gold badge4 silver badges12 bronze badges 6
  • 2 You have an extra parenthesis in your example after the "aboutMe.html" – Jesan Fafon Commented May 23, 2014 at 20:08
  • Check the console for errors? – j08691 Commented May 23, 2014 at 20:09
  • Basic troubleshooting ... does your panel show any 404s? Have you added alerts to see if the listener is firing? Etc – WillardSolutions Commented May 23, 2014 at 20:09
  • The console doesnt show any errors – SjoerdvdBelt Commented May 23, 2014 at 20:12
  • 3 Interestingly, his mistake doesn't result in a syntax error. The ma turns from being an argument separator to the ma operator. – Barmar Commented May 23, 2014 at 20:12
 |  Show 1 more ment

2 Answers 2

Reset to default 5

Your parentheses and braces are wrong. It should be:

$(".information").click( function() {
    $.get("aboutMe.html", function(data){
        $("#text").html(data);
    });
});

Your callback function was outside the argument list of $.get().

Hope this will work for ýou

$(function() {

$('.information').click(function(){


$('#text').load("aboutMe.html");

});

});
发布评论

评论列表(0)

  1. 暂无评论