Search code examples
javascriptjquerycustom-tag

How to get the value of a custom tag with jQuery


I have a custom tag with format

<ie:menuitems id="ieMenu">Hello World</ie:menuitems>

Now my task is to change the 'Hello World' text, but I am unable to retrieve the value with jQuery/JavaScript, i can get the element for sure because $('#ieMenu").size() gives me 1 as output, but to get the value i tried .text(), .contents(), .val(), .html() but none worked, please help

thanks in advance

EDIT--------------------------------------------------

I think I should mention something here, the above code sample is copied from the page source, i am not sure if this helps you in some way or not, what i wanted to say this is the converted html, and i am running my code in a button click not in page load


Solution

  • Amazing I don't know is it correct or not but I checked and found "Hello World" by using

    $("#ieMenu")[0].nextSibling.nodeValue 
    

    and you can assign value as

    $("#ieMenu")[0].nextSibling.nodeValue = "Test"