开发者

jquery selector inside a table with multiple div's

i am trying to reach a value in my code which is in a loop through jquery selector but i cannot figure it out because i am still a noob in jquery selector:

  <tr >
    <td class="qtip" title="asjdasd">
        <?php
        foreach ($this->titles as $title) {
        ?>

            <div class="title" style="font-weight: bold" >
            <?php echo $title['chapter_name']; ?>
        </div>
        <?php foreach ($title['videotitle'] as $video) {
        ?>


                <div class="title">
                    <input type="hidden" id="hiddenid" value="<?php echo $video['id'] ?>">
            <?php echo $video['video_title']; ?>
            </div>
            <div>
            <?php echo date('h:i:s', $video['video_time']) ?>
            </div>

            <div><?php echo $video['date_created'] ?></div>
        <?php if (isset($this->Videos['user_id'])) {
        ?>
        <?php if (isset($video['file_path'])) {
        ?>开发者_运维技巧;
                        <div> <a href="<?php echo $video['file_path']; ?>" target="_blank"> <img src="/images/white_folder.jpg" alt="" /></a></div>
        <?php } else {
        ?>
                        <div> <a href="#" target="_blank"></a></div>
        <?php } ?>
        <?php } else {
        ?>
                    <div>  <a href="/auth/login" target="_blank"> <img src="/images/white_folder.jpg" alt="" /></a></div>
        <?php } ?>
    <!--                    <div> <a href="/mediaplayer/player.swf?width=700&height=500&file=<? //php echo $video['video_path'];                                        ?>&image=<? //php echo str_replace('.flv', '.jpg', str_replace('/flv/', '/thumb/', $video['video_path']))                                        ?>&skin=<? //php echo URL_ADDRESS                                        ?>/mediaplayer/carbon/carbon.xml" rel="shadowbox" title="<? //php echo $video['video_title']                                        ?>" ><img src="/images/white_vid.jpg" alt="" /></a></div>-->

                <div class="jwbox">
                    <img width="21" height="27" alt="" title="" src="/images/white_vid.jpg"/>
                    <div class="jwbox_hidden">
                        <div  class="jwbox_content">
                    <?php
                    echo $video['vid_code'];
                    ?>

i want to reach to this Hidden value and get its value:

                    <input type="hidden" id="videoid" value="<?php echo $video['videoid'] ?>">

                    <script type='text/javascript'>

                        var timerinterval
                        jwplayer('player2').onPlay(function() {
                            timerinterval=setInterval('timer()',1000)});
                        jwplayer('player2').onPause(function() {
                            stopTimer()});
                        jwplayer('player2').onComplete(function(){
                            stopTimer()});


                    </script>
                    <p><?php echo $video['video_title'] ?></p>
                    <a href="javascript:void(0)">  <p  id ="fav" font-color="green">add to favourite  </p></a>
                </div>
            </div>

        </di


To get ahold of the value in:

<input type="hidden" id="hiddenid" value="<?php echo $video['id'] ?>"> 

use

$("input#hiddenid").val();

Since you are new note the following things:

ID's must allways be unique and are selected using

$("#idName")

Class's can be groups of tags selected using

$(".className")

to select all img elements use $

$("img")

to select an exact element with tag > classname > id

$("img.className#id")


What about

   $('#hiddenid').val();


As you define an ID for it, it is presumably (at least it should be), the only element with that ID, and as such you can get it simply by using $("#videoid") and its value with $("#videoid").val()


$(".jwbox_hidden").text(); would probably give you the content of that div using the class selector.

You should however, consider your usage. Perhaps use a hidden input with a value set in your php instead. If you are using elements to hold hidden data, try to use id's rather than classes since you want to query only one instance of that element on your page.

e.g

<input type="hidden" value="<?php echo $video['vid_code']; ?>" id="jwbox_hidden" />

you could then simply query it using $("#jwbox_hidden").val(); using the id selector.

More information on selector is here It's actually quite easy once you get the hang of it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜