Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

DOM manipulation in client script

Hafsa1
Mega Sage

I want to hide (x) icon using client script, how can I use it in getElementById

find_real_file.png

6 REPLIES 6

Oh, and here's the client script code to hide your "x" for tags:

function onLoad() {
	addAfterPageLoadedEvent(function(){
		var w = false;
		if (top.document.getElementById('gsft_main'))
			w = top.document.getElementById('gsft_main').contentWindow.document;
		if (!w) {
			if (document) {	w = document; }
			else if (top) {	w = top.document; }
		}
		var tmo = w.getElementById('toggleMoreOptions');
		if (tmo) {
			tmo.onclick = function(){
				var counter = 0;
				var hidden = false;
				var w = false;
				if (top.document.getElementById('gsft_main'))
					w = top.document.getElementById('gsft_main').contentWindow.document;
				if (!w) {
					if (document) {	w = document; }
					else if (top) {	w = top.document; }
				}
				function hideA() {
					if (++counter >= 1000 || hidden) {
						return;
					}
					setTimeout(function(){
						if (w) {
							var tags = w.getElementById('document_tags');
							if (tags) {
								var a = tags.getElementsByTagName('a');
								if (!a.length)
									hideA();
								for (var i = 0; i < a.length; i++) {
									if (a[i].classList.contains('tagit-close')) {
										a[i].style.display = "none";
										hidden = true;
									}
								}
							} else {
								console.warn("NO TAGS FOUND");
							}
						}
					},1);
				}
				hideA();
			};
		}
	});
}

 

find_real_file.png

Tim82
Tera Contributor

Very good, worked for me as:
var clear_secondary_address = top.document.getElementById('address_two').value = '';

👍