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

  • Home
  • SEARCH
  • 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 1097661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:27:57+00:00 2026-05-17T00:27:57+00:00

My div has no id . can i call a jquery function on click

  • 0

My div has no id .
can i call a jquery function on click of that div

div identified by class used in div.

<div class="divclass">

how can i call

$('.divclass').click(

???

  • 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-17T00:27:58+00:00Added an answer on May 17, 2026 at 12:27 am

    To assign a click handler, you can do this:

    $('div.divclass').click(function() {
        alert('i was clicked');
    });
    

    …or this, which is the same thing:

    $('div.divclass').bind('click', function() {
        alert('i was clicked');
    });
    

    Here’s an example: http://jsfiddle.net/MAKHh/


    EDIT:

    As noted by @mcgrailm, there’s another means of firing code on the click of an element called .live(). As well as a related one called .delegate().

    With live(), the handler will fire regardless of when the element is added to the page.

    $('div.divclass').live('click', function() {
        alert('i was clicked');
    });
    

    Or with .delegate() you call it agains a container, and elements added to that container at any time will fire the handler.

    $('.someContainer').delegate('div.divclass', 'click', function() {
        alert('i was clicked');
    });
    

    Or if you wanted to .trigger() a click event, do this:

    $('div.divclass').click();
    

    Or this:

    $('div.divclass').trigger('click');
    

    You can also call the handler without triggering the event.

    $('div.divclass').triggerHandler('click');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been writing a simple jquery function that turns a div with a list
How can i suppress words in a DIV (which has a defined width and
How can I flip the modal below which has multiple divs? <div id=modal> <div
i have a click event for $('#blah div'). div has text inside of it
To clarify, how can run a custom function right before jquery's validation plugin runs
My method fades a div box out and has a callback that calls a
I want to raise a jQuery Dialog box which has 2 buttons. So that
The click function works for the <li> element that is part of the HTML
selectedsong div has differents links with differents rel=... and the problems is... I'm using
I'm using the Twitter Bootstrap fixed layout where the container div has: margin-left: auto;

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.