Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67441

JQuery get next/closest element

$
0
0

I have the following HTML markup and inside my update_project function, i am trying to get the css property of the selected li inside <ul class="dropdown-menu pull-right"> so i tried

$('#brief_48').closest('a').find('ul li').css('background-color');

but that returns undefined

my function has the following arguments function update_project(sequence, field, new_value) {

new_value is the text of the li that is clicked

so is is possible to get the li that has been clicked based on the text?

<tr>
    <td>-</td>
    <td><a href="javascript:void(0);" onclick="LoadModal('/section/projects?action=edit&amp;seq=48');">-</a></td>
    <td>-</td>
    <td>14-11-2019</td>
    <td align="center">
        <div class="input-group-btn">
            <button type="button" class="btn btn-xs dropdown-toggle" data-toggle="dropdown" style="color:#ffffff; background-color:#0000ff; width:150px;" id="brief_48" autocomplete="off">Waiting <span class="fa fa-caret-down"></span></button>
            <ul class="dropdown-menu pull-right">
                <li style="background-color:#E8E8E8;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'none');">none</a></li>
                <li style="background-color:#008000;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'Done');">Done</a></li>
                <li style="background-color:#ff0000;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'Stuck');">Stuck</a></li>
                <li style="background-color:#0000ff;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'Waiting');">Waiting</a></li>
                <li style="background-color:#ffa500;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'In progress');">In progress</a></li>
                <li style="background-color:Black;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'Billed');">Billed</a></li>
                <li style="background-color:Brown;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'To budget');">To budget</a></li>
                <li style="background-color:Magenta;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'brief', 'With client');">With client</a></li>
            </ul>
        </div>
    </td>
    <td align="center">
        <div class="input-group-btn">
            <button type="button" class="btn btn-xs dropdown-toggle" data-toggle="dropdown" style="color:#ffffff; background-color:; width:150px;"> <span class="fa fa-caret-down"></span></button>
            <ul class="dropdown-menu pull-right">
                <li style="background-color:#E8E8E8;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'none');">none</a></li>
                <li style="background-color:#008000;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'Done');">Done</a></li>
                <li style="background-color:#ff0000;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'Stuck');">Stuck</a></li>
                <li style="background-color:#0000ff;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'Waiting');">Waiting</a></li>
                <li style="background-color:#ffa500;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'In progress');">In progress</a></li>
                <li style="background-color:Black;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'Billed');">Billed</a></li>
                <li style="background-color:Brown;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'To budget');">To budget</a></li>
                <li style="background-color:Magenta;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'budget', 'With client');">With client</a></li>
            </ul>
        </div>
    </td>
    <td align="center">
        <div class="input-group-btn">
            <button type="button" class="btn btn-xs dropdown-toggle" data-toggle="dropdown" style="color:#ffffff; background-color:; width:150px;"> <span class="fa fa-caret-down"></span></button>
            <ul class="dropdown-menu pull-right">
                <li style="background-color:#E8E8E8;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'none');">none</a></li>
                <li style="background-color:#008000;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'Done');">Done</a></li>
                <li style="background-color:#ff0000;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'Stuck');">Stuck</a></li>
                <li style="background-color:#0000ff;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'Waiting');">Waiting</a></li>
                <li style="background-color:#ffa500;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'In progress');">In progress</a></li>
                <li style="background-color:Black;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'Billed');">Billed</a></li>
                <li style="background-color:Brown;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'To budget');">To budget</a></li>
                <li style="background-color:Magenta;"><a style="color:#ffffff;" href="javascript:void(0);" onclick="update_project('48', 'status', 'With client');">With client</a></li>
            </ul>
        </div>
    </td>
    <td align="center"><a href="javascript:void(0);" class="btn btn-xs btn-default" onclick="archive_project('48', '1');">Archive</a></td>
</tr>

Viewing all articles
Browse latest Browse all 67441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>