DD.
DD.

Reputation: 973

How to call particular ID within another ID in html?

This is the content of page2.html

<div data-role="page" data-theme="b" id="pageone">  
    <div data-role="content">
        <div class="site_wrap wrap">
            <div class="img_slides_wrap slides_wrap wrap">  

            <div>    <img id="slide1" class="img_slide slide active" src="img/slide0.jpg" alt="" title=""/> </div>
             <div>   <img id="slide2" class="img_slide slide" src="img/slide1.jpg" alt="" title=""/> </div>
             <div>   <img id="slide3" class="img_slide slide" src="img/slide2.jpg" alt="" title=""/> </div>
             <div>    <img id="slide4" class="img_slide slide" src="img/slide3.jpg" alt="" title=""/> </div>
             <div>   <img id="slide5" class="img_slide slide" src="img/slide4.jpg" alt="" title=""/> </div>
            </div>
        </div> 
        <a href="#pagetwo">SHARE</a>
    </div>
</div>

now i need to get "slide3" on Onclick of third image from page1.html heres the code for it

<li> <a href='page1.html#pageone#slide3' ><img src="img/thumb/a.jpg" alt="Image a" width="30" height="48"/></a></li>

The issue is i'm not able to get slide3 when clicked on third image from page2.html instead able to get 1st image... where i'm i going wrong please help me.

Upvotes: 0

Views: 1579

Answers (2)

Dhanith Suryavansi
Dhanith Suryavansi

Reputation: 29

Call Each id from number ranging from 1 to 10.Like #slide1 to #slide10.And you can easily call it like href="page1.html#slide3".

Upvotes: 0

Quentin
Quentin

Reputation: 943510

An ID must be unique within a document.

You cannot have duplicate IDs.

URL fragment identifier syntax does not support "X in Y" syntax as "X" must be unique so "in Y" will be redundant.

All you need, if your HTML is valid, is href="page1.html#slide3".

Upvotes: 3

Related Questions