How to get the value of an element

<a onclick="merchandiseCzc("/front/merchandise/detail/FDM/CAN003066G/",1, "", "CAN003066G", "","_blank")" class="u_goods_tit" title="/0.5g*12s*3 ">
                                                <span class="m_tag m_tag_kw">
                                                            OTC
                                                </span>

                                            
                                                <span class="u_goods_spec" >/0.5g*12s*3  </span>
                                            </a>

as in the code above, how does jQuery get only the value of element a, "Jianwei Xiaoshi tablet"? Boss, please give me some advice.

Apr.05,2021

the idea goes something like this:

//
var a = document.getElementById('aaa');
//dom
console.log(a.childNodes);
//a  
for(var i = 0; i < a.childNodes.length; iPP) {
    if(a.childNodes[i].nodeType === 3) {
        console.log(a.childNodes[i].nodeValue);
    }
}

//jQuery  
The html, value of

is troublesome. Why not consider adding a label to this value? It is convenient to take the value and add css modification. You can also add a key-value pair of attributes to the a tag to store this.

Menu