Which of the following code is better in building a delete -action for removing a question?
1 My code
<a href='index.php?delete_post=777>delete</a>
2 Stack Overflow’s code
<a id="delete_post_777>">delete</a>
I do not understand completely how Stack Overflow’s delete -button works, since it points to no URL.
The id apparently can only be used by CSS and JavaScript.
Stack Overflow apparently uses JavaScript for the action.
- How can you put start the
delete-action based on the content of CSS -file by JavaScript? - How can you start a SQL delete -command by JavaScript? I know how you can do that by PHP, but not by JavaScript.
The url you are looking for is in the js code. Personally I would have an id that identifies each <a> tag with a specific post, comment… or whatever, and then have a class=”delete_something” on each one, this then posts to the correct place using javascript.
Like so: