• Recent Questions
  • Popular Questions

Help with variables in Jquery + variable +. Trying to concatenate variables together.?

I am trying to declare the variables and stuff and make the variables appear in this div with the class of footer. Please help me figure out how I can add it to it in Jquery. I have tried .I DO NOT DO NOT DO NOT WANT TO USE DOCUMENT.WRITE even if it works. Instead of append I have also tried .html and neither worked. Please help. I have spent hours trying to fix this.
$(document).ready(function(){
$(‘#printdate’).append(fulldate);
});

AND

$(document).ready(function(){
$(‘#printdate’).append( ‘ ” ” + dayss[dayy] + “, ” + monthss[monthh] +” “+ dayyss +”, “+ yearr +” “‘ );
});
NOTHING SEEMS TO WORK…

just what i named my variables. and when i used the HTML it didn’t work either. I fixed it now though. Thanks for explaining and enjoy the best answer

    Silent
    Posted 10 months ago

    Well, in this version:

    $(document).ready(function(){
    $(‘#printdate’).append( ‘ ” ” + dayss[dayy] + “, ” + monthss[monthh] +” “+ dayyss +”, “+ yearr +” “‘ );
    });

    You have the entire thing wrapped in single quotes for no reason.

    You also may be misunderstanding what the append() function is supposed to do. It’s used to add an entire HTML element as the last child of the element it’s called on. What you seem to be trying to do is add some text to the content of the element. You would do that with the html() function, as you seem to have figured out already.

    Could you explain a bit more about how it “doesn’t work”? Is there an error message?

    Is there a reason you have random extra letters at the ends of all your variable names?

Answer this Question :

You must be logged in to post an answer. Signup Here, it takes 5 seconds :)

Other Questions