www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to select element in div (jquery)

  1. #1
    Join Date
    Feb 2012
    Posts
    33

    how to select element in div (jquery)

    Hello everyone

    I'm just a beginer. I would like to ask you how to select a img in div onmouse over for example.
    HTML Code:
    <div class"first class"><img class"second" src""></div>
    <div class"first class"><img class"second" src""></div>
    <div class"first class"><img class"second" src""></div>
    <div class"first class"><img class"second" src""></div>
    <div class"first class"><img class"second" src""></div>
    <div class"first class"><img class"second" src""></div>
    <div class"first class"><img class"second" src""></div>
    When i mouseon first div, the img (only in this div) should be visible.
    I serched in google but the selectors not function properly in my case


    I have something like that:
    HTML Code:
    $("document").ready(
    	function()
    	{
    	
    		
    		$(".first_class").mouseover(
    			function()
    			{
    				select inner img
    			
    				
    			}		
    		)
    		$(".first_class").mouseout(
    			function()
    			{
    				select inner img
    				
    			}		
    		)
    	}
    );

    Thanks for help
    Last edited by johny1000; 03-14-2012 at 09:57 AM.

  2. #2
    Join Date
    Apr 2010
    Location
    Salem,Ma
    Posts
    623
    Code:
    $(document).ready(function(){ 
    
    $("div.first.class").hover(
      function () {
        $(this).find("img").show();
      }, 
      function () {
        $(this).find("img").hide();
      });
    
    });
    this will do it. also its:

    class="first class" and src=""

    - dont forget to add alt="some text about this image" in case yoyur image doesnt load or other issues come into play at least you will have alt test to display

    if you want to use jQuery, you will reference this page alot: http://api.jquery.com/category/selectors/

    it shows you how to use the jquery syntax to select elements.

  3. #3
    Join Date
    Feb 2012
    Posts
    33
    Thanks a lot its working

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles