Jquery - Select a span's content inside of a specific div

前端 未结 1 749
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 12:42

I am trying to select the content inside of a div but the CMS I am using adds this span inside of my div and so now I am not sure how to select the content inside of it. That sp

相关标签:
1条回答
  • 2021-01-27 13:29

    Do this:

    var emailAddress = null;
    
     $(document).ready(function() {
        emailAddress = $('#emailAddress span').text();
        console.log(emailAddress);
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="emailAddress"><span merge-tag="{{user.email}}">CONTENT HERE IS WHAT THE VARIABLE SHOULD BE SET TO</span></div>

    0 讨论(0)
提交回复
热议问题