?
Solved

click event

Posted on 2013-07-01
4
Medium Priority
?
264 Views
Last Modified: 2013-07-01
The iphosting site should function like the seodhost site... but i put some code for the "+" sign to click and toggle like the seodhost site but it does not...there is no error in the console either so im not sure why this is happening.

http://iphosting.info/about/index.html

<script type="text/javascript">
//$(document).ready(function(){
	$("#title").bind("click",function(){

		alert('hello');
	});
//});


</script>

Open in new window






http://www.seodhost.com/about/index.html
0
Comment
Question by:Moizsaif123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39289991
Your 'document ready' block is commented out !
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 39290028
Hmmm - just looked at the code for both sites and the code you've posted above is not what is used for the + click. On the seodhost site you have the following in the head:

<script type="text/javascript">
   function CallShowHideDivContentAboutUs(id_about) {
      //Show div and reset all others
      $("#"+id_about).slideToggle(975).siblings(id_about).slideUp("slow");
   }
</script>

Open in new window

You don't have that in the other site.
0
 
LVL 4

Author Comment

by:Moizsaif123
ID: 39290230
This solution works although it should work with the code below as well...not sure why..

$("#bg_about").click(function()
alert('hello');
});

Open in new window

0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39290253
The code you've posted above is missing an opening curly bracket. It should be:

$("#bg_about").click(function() {
     alert('hello');
});

Open in new window

Rather than adding a click event to each title, why not just add the event based on class, and attach the event in jQuery rather than the inline onClick event. It keeps it all alot neater. Have a play with this:

http://jsfiddle.net/ChrisStanyon/rraPE/
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question