简体   繁体   中英

Change the text of a span element on click on an anchor element

<div class="input-group-btn search-panel" id="change-text">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
        <span id="search_concept change-text-span">Select Location</span>
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu scrollable-menu" role="menu">
        <li>
            <a href="#Link" id="change-text-a">Odisha</a>
        </li>
    </ul>
</div>

In the above code, I need to change the text of the span element on click of the a element. How can I do this?

Please Help.

Try this:

$("#change-text-a").click(function() {
   $(".caret").text("SEt content here");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM