Page 1 of 1

How to change the text of an <a> tag using JQuery

Posted: 2025-01-25 05:12
by dlee
Below is a screen capture of my app and the red box if the area I wish to change the text for programmatically. I have tried every piece of JQuery code I can find regarding this and no luck.

Hope you guys can help!
TD

Here is the page source for this area in question:

Code: Select all

<th class="inspections-fld_10" ><a href="inspections_view.php?SortDirection=asc&SortField=23" onClick="document.forms[0].SelectedID.value = ''; [attachment=0]jquery question.jpg[/attachment]document.forms[0].NoDV.value=1; document.forms[0].SortDirection.value='asc'; document.forms[0].SortField.value = '23'; document.forms[0].submit(); return false;" class="TableHeader">fld_10</a></th>

Re: How to change the text of an <a> tag using JQuery

Posted: 2025-01-25 07:39
by jsetzer
How to change the text of an <a> tag using JQuery
How to change the link-text of a table column header in AppGini table view

Code

Code: Select all

// file: hooks/TABLENAME-tv.js

// change TABLENAME, COLUMNNAME, NEW_TEXT accordingly
const TABLENAME = 'partners';
const COLUMNNAME = 'label'

let NEW_TEXT = 'This is my new column header';

// do not change below
jQuery(()=>{
    jQuery(`table[data-tablename="${TABLENAME}"] > thead > tr > th.${TABLENAME}-${COLUMNNAME} > a:eq(0)`).text(NEW_TEXT)
});
Result
chrome_ow1Lu7eZtf.png
chrome_ow1Lu7eZtf.png (16.92 KiB) Viewed 8885 times
Tip
You can wrap the code in a global function for example in hooks/header-extras.php, then call it from whereever you need, for example relabelTableViewHeader('mytable', 'column1', 'New Text');

Hope this helps.

Re: How to change the text of an <a> tag using JQuery

Posted: 2025-01-25 22:11
by dlee
Thank you Jan !!! I will try this and report back

Thanks again my friend,
TD

Re: How to change the text of an <a> tag using JQuery

Posted: 2025-01-25 22:23
by dlee
Jan your code works PERFECTLY !

Thanks,
TD