JS – Splitting a string and looping through results

You can use .split() to split a string on a specified character with the results returned as an array. So then it’s just a matter of looping through the array:

// given your existing variable
// feedUpdateResponse = "div1/div2/div3/div4" as set in the
// code in the question, add this:

var a = feedUpdateResponse.split("https://stackoverflow.com/"),
    i;

for (i = 0; i < a.length; i++) {
    document.getElementById("updateAvailable_" + a[i]).style.visibility
                                                                 = "visible";
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)