jquery - Multiple variables using same value for different IDs -


i'm using window location , div id of includecmscontent1, includecmscontent2, includecmscontent3 on single page application. when conditions met external content injected @ id.

however, i'm finding 1 of 3 variables firing, first 1 actually, because if includecmscontent3 present on page, id won't fire because includecmscontent1 taking precedence.

how can solve this? page same, value same, id of includecmscontent1/2/3 swap on same page.

var tceapplicationnowaiver = "tceapplication.aspx" var tceapplicationwaiver = "tceapplication.aspx" var tceapplicationnoteligible = "tceapplication.aspx"  if (window.location.href.tolowercase().indexof(tceapplicationnowaiver.tolowercase()) >= 0) {             $("#includecmscontent1").load("http://www.example.com/tce-application-nowaiver.htm #externalcontent"); } else if (window.location.href.tolowercase().indexof(tceapplicationwaiver.tolowercase()) >= 0) {             $("#includecmscontent2").load("http://www.example.com/tce-application-waiver.htm #externalcontent"); } else if (window.location.href.tolowercase().indexof(tceapplicationnoteligible.tolowercase()) >= 0) {             $("#includecmscontent3").load("http://www.example.com/not-eligible.htm #externalcontent"); } 

remove else statement conditions triggered:

if (window.location.href.tolowercase().indexof(tceapplicationnowaiver.tolowercase()) >= 0) {     $("#includecmscontent1").load("http://www.example.com/tce-application-nowaiver.htm #externalcontent"); }  if (window.location.href.tolowercase().indexof(tceapplicationwaiver.tolowercase()) >= 0) {     $("#includecmscontent2").load("http://www.example.com/tce-application-waiver.htm #externalcontent"); }  if (window.location.href.tolowercase().indexof(tceapplicationnoteligible.tolowercase()) >= 0) {     $("#includecmscontent3").load("http://www.example.com/not-eligible.htm #externalcontent"); } 

hope helps.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -