Search code examples
javascriptjquerygoogle-chrome-extensionregular-language

javascript regular expression select html element with class="product" from string


lets say i use jquery.get to retrive a website to string and how am i gonna select the whole table with class=product from it? $() seem cant work on string ....


Solution

  • You can use .load() for this, like this:

    $("#elementToLoadIn").load("myPage.htm .product");
    

    The format is "url selector" (note the space there).

    The $.get alternative is:

    $.get("myPage.htm", function(data) {
       $("#elementToLoadIn").html($(".product", data));
    });