How can I send POST data and navigate with JQuery?

前端 未结 4 1938
[愿得一人]
[愿得一人] 2021-01-02 19:51

On my blog I have a lot of

 blocks containing code snippets.

What I want to do is add a .click() handler to all the

4条回答
  •  半阙折子戏
    2021-01-02 20:41

    If your code snippets are stored somewhere in a database or files, I suggest you just link the snippets to a page where you get the snippet based on some identifier.

    If the snippets are only contained in your html, and you just want to display them in a cleaner way, you shouldn't need any ajax posting. You might want to Use a hover div or a jquery plugin, that pop's up and shows a cleaner piece of code obtained from the pre element, something like:

    $('pre').click(function() {
       var code = $(this).html(); //this is the pre contents you  want to send
       $('#hoverDiv').html(code).show();
    });
    

提交回复
热议问题