Talor Gavin Talor Gavin - 1 month ago 5
Javascript Question

Javascript/Jquery to grab ID with different numbers

So I have this to change the attributes

title: "Subscribe via RSS"
$('#ctl00_ContentPlaceHolder1_ctl14_ucCal_hlRss img').attr({
title: "Subscribe via RSS",
alt: "Subscribe via RSS"

It works well however I need to add this to multiple different websites where the "ctl14" will change (For example on another site it will be "ctl60"). Is there a way I can modify this to make sure it picks any numbers after "ctl##" then continues on with _ucCal_hlRss and _ucCal_hlRss img?


Try this selector, which will get all elements with an ID starting with ctl00_ContentPlaceHolder1_ctl and finishing with _ucCal_hlRss.