0

I'm willing to use jQuery API to edit HTMl. E.g. instead of manually inserting

tags in more than 30 identical spots within html code I want to use jQuery after() method. (actually, it might be pure JS)

It feels like a special environment must be created for this goal? However I don't know what exactly to do.

P.S. I'm on Mac.

1
  • 1
    We're more than happy to help but can you please provide an example of what tags you want where in your HTML markup? And provide an example of what you've tried so far utilizing jQuery. Commented Aug 11, 2015 at 17:25

1 Answer 1

1

Add <script src="jquery-1.11.3.min.js"></script> to the head element in your HTML.

<head>
<script src="jquery-1.11.3.min.js"></script>
</head>

Then you can use jQuery in any <script> tag.

Read this page: http://www.w3schools.com/jquery/jquery_get_started.asp for more info.


For jQuery's after function:

$("button").click(function(){
    $("p").after("<p>Hello world!</p>");
});

This code inserts a p paragraph tag after each p element in your HTML.

For more on the after function, read here: http://www.w3schools.com/jquery/html_after.asp

Sign up to request clarification or add additional context in comments.

2 Comments

I know how to use jQuery for general purposes. Please, pay attention at my question more closely. I meant using jQuery functions for HTML code editing. I don't jQuery to be executed on client side.
If you don't want jQuery on client side, then use node.js, related to stackoverflow.com/questions/15109465/…. Or, you could use ASP.net with codebehind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.