0

I have a list web part on a page and want to change the text, and href, from the standard new item text to something custom.

I can successfully get the (+) new item text with the following:

var x = $('#idHomePageNewItem').first('span').text();
alert(x);

However, I can't set the text using the same logic:

$('#idHomePageNewItem').first('span').text('hello there');
1

The following code for your reference.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
var jq = $.noConflict();
jq(document).ready(function(){
    jq('#idHomePageNewItem').text("hello there");
    jq('#idHomePageNewItem').attr("href","http://www.bing.com");
    jq('#idHomePageNewItem').attr("onclick","");
});
</script>

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.