开发者

Jquery is not working when i try to use it for google custom search?

开发者 https://www.devze.com 2023-03-07 17:26 出处:网络
In my case, jQuery is not working. I don\'t know where I am wrong. It can be confliction with some other js files but not sure. See below screenshot.

In my case, jQuery is not working. I don't know where I am wrong. It can be confliction with some other js files but not sure. See below screenshot.

Jquery is not working when i try to use it for google custom search?

In this screen shot you are seeing google custom search box which is ajax based. My problem is when i click on search box then bottom Premium sales jobs contaner should be hidden. For this i have used this jQuery code :

$(document).ready(function(){
    $(".gsc-search-button").click(function(){
        $("#container_table").hide();
    });
)};

I have included jQuery library with correct path. I have also used alert() after document.ready to check it is working or not..But its not working.

.gsc-search-button is the class of search button.
#container_table is the id of that table which I want to hide.

The search data will be load into like div which is initially look like this : <div id="cse">Loading</div> and after search iframe placed into this div and replaced Loading String.

I have also tried below javascript code :

if(document.getElementById('cse').innerHTML != "Loading") {
  document.getElementById('#container_table').style.display = "none";
  }

But it'开发者_StackOverflow中文版s not working.


You're confusing the CSS style selectors in jQuery with the ID in the following code:

document.getElementById('#container_table')

It might work if you remove the '#' symbol:

document.getElementById('container_table')

But another way that would clear the element with "cse" identity would be

$('#cse').text('')
0

精彩评论

暂无评论...
验证码 换一张
取 消