0

I want to use get parameter for enabling a js event.

for example when I run this url example.com?verify

I need to run click event of element that have data-event="verify"

my try:(not work)

    $(".plan .reqPage").each(function(index, element) {
        var para = document.location.search;
        var btn = $(".plan .subject:eq("+index+")");
        if(para.length>0)
        {
            var tab = btn.data('event');
            var yyy1 = "?"+tab;
            var yyy2 = "?"+tab+"&";
            var yyy3 = "&"+tab;
            var yyy4 = "&"+tab+"&";
            if(para.indexOf(yyy1)>=0 || para.indexOf(yyy2)>=0 || para.indexOf(yyy3)>=0 || para.indexOf(yyy4)>=0)
            { btn.click(); return false; }
        }else if(index>0) $(this).hide();
    });

is it possible?

Pooya
  • 1,508
  • 3
  • 17
  • 38
  • no that is diffrent. I dont have some var like returnurl. ?returnurl=admin – Pooya May 17 '14 at 11:23
  • 1
    the essence of the question is the same. Retrieving the value of a GET parameter is what this question focuses on. Your question, after retrieving the value, just needs to set the `data-event` attribute to the GET parameter. – the6p4c May 17 '14 at 11:27
  • Actually, that does look like a duplicate, and now you want to parse the querystring as well, making it an almost perfect duplicate ? – adeneo May 17 '14 at 11:29

0 Answers0