Help with jQuery conditional expression

I am trying to run some jQuery script on a specific page, but only if a specific page is loaded.

Scenario: we have one page that loads (i.e. webpage.aspx), and loads other content based on a link click. (i.e. webpage.aspx? contentId = 1, webpage.aspx? contentId = 2, webpage.aspx? contentId = 3, etc.). Here is my problem. I need to delete a specific part of the page if I pull out only one specific content. I am trying to do this in jQuery and don't seem to understand.

This is what I have worked with so far. I understand that this is not correct, but hopefully this gives you a starting point for work.

Thank.

CODE:

$(window).load(function() {
   var $deleteNewRow = $("div.col.w140 tbody:first").find("td:first").parent().remove();
   if($('#dealer-info h1').indexOf('Ferrari') != -1) {
      $deleteNewRow
   }
});
+3
2

, $deleteNewRow, jQuery, . if, - ( , if .text()):

$(window).load(function() {
   if($('#dealer-info h1').text().indexOf('Ferrari') != -1) {
      $("div.col.w140 tbody:first").find("td:first").parent().remove();
   }
});
+1

jQuery :contains . docs. , , remove.

$("div.col.w140 tbody:first").find("td:first").parent().remove();
0

Source: https://habr.com/ru/post/1756266/


All Articles