Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7680395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:06:20+00:00 2026-05-31T18:06:20+00:00

THIS IS THE FULL SCRIPT http://goo.gl/HoCxk I have a problem with this function: $(‘.message’).click(function(){

  • 0

THIS IS THE FULL SCRIPT

http://goo.gl/HoCxk

I have a problem with this function:

    $('.message').click(function(){
    alert("it works");
    var clicked_msg=$(this);
    $('#current_message').html(clicked_msg.attr("id"));
});

If instead of the above I add an onclick=”msgClicked()”, and then do something like this:

function msgClicked(){
var x=document.getElementById("current_message");alert("it works");x.innerHTML("test");}

The jQuery library is obviously imported as literally everything else is done using the jQuery framework and all the other functions implemented on the messaging system are jQuery. Everything works perfect there but for some reason I can’t figure out what is wrong with this one.

If any of you are willing to help out and you need to see what is actually going on, please let me know and I will create an account for you on my website. Removing all the protection from the content would take a looong long time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:06:21+00:00Added an answer on May 31, 2026 at 6:06 pm

    How are you?

    Usually these little annoyances are caused because:

    • You made a typo (such as .message being incorrectly spelled in either JS or the HTML)
    • You are trying to assign this function to an element which has not been yet created

    Just to be sure, try this:

    alert($('.message').length)
    $('.message').click(function(){
        alert("it works");
        var clicked_msg=$(this);
        $('#current_message').html(clicked_msg.attr("id"));
    });
    

    If it outputs 0, it’s because one of the two problems above might be happening, and then, try this:

    $(function(){
        alert('The page loaded!');
        alert('.message elements in page: ' + $('.message').length);
        $('.message').click(function(){
            alert("it works");
            var clicked_msg=$(this);
            $('#current_message').html(clicked_msg.attr("id"));
        });
    });
    

    If you don’t get any alert messages, there’s something wrong with your jQuery import, and it might be a conflict (such as including jQuery twice!)

    If the .message elements in page are more than 0, then it was the second issue (you were trying to assign the .click event to an element which hadn’t been yet created)

    And if it still says 0 elements, then there are no elements with class “message” created.

    I hope this points you in the right direction.

    Cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following in my <head> section: <script type=text/javascript> $(function(){ $(h5).live(click, function(){ alert($(this).tmplItem());
I want to generalize this: <html> <script src=http://code.jquery.com/jquery-latest.js></script> <script> $(function(){ $('#target1').click(function() { $.post(process_form.php, $(#JqPostForm1).serialize(),
i have this function to return the full directory tree : function getDirectory( $path
We have a problem on Debian server and PHP version 4.4.4-8+etch6. In this script
I have script like this : fullscript.sh if [ ! -f /opt/laks/linux-2.6.33.2.tar.bz2 ] then
I have a database full of text fields that look like this: (paragraph of
Here is the full sample script which demonstrates the problem, inner tabs company/department come
Does anyone have an explanation of how javascript could do this. Somehow this function
I have a jsp page as: <html> <head> <title>Try in JNLP</title> <script src=http://www.java.com/js/deployJava.js></script> <script>
$(body).append( <p id='Zoom'>Send to: <b> + full + </b> <div id='fb-root'></div><script src='http://connect.facebook.net/en_US/all.js#xfbml=1'></script><fb:send href=' +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.