/* Template Name: Users */ ?> .container{ width: 800px; } .left{ float:left; width: 300px; background: ##66CDAA; border-right: thick-solid #fff; } .right{ overflow: hidden; width: 500px; background: powderblue; } <?php get_header(); ?> <div id="primary" class="content-area"> <div class="container"> <div class="left" id="xyz"> <?php $sql ="SELECT * FROM wp_users"; $results = $wpdb->get_results($sql) or die(mysql_error()); foreach( $results as $result ){ ?> <?php } ?> <table><tbody><tr><th>Name</th><th>Gravatar Image</th><th>Add to Div</th></tr><tr><td id="<?php echo $result->ID; ?>"> <?php echo $result->display_name; ?> </td><td> <?php echo get_avatar( $result->user_email, 42); ?> </td><td> <p>Added</p> </td></tr></tbody></table> </div> <div class="right"> <p>Added Users</p> <table class="table"><tbody><tr><th>Name</th><th> </th><th>Image</th></tr></tbody></table> </div> </div> </div> <?php get_footer(); ?>
(function($) { $(document).ready(function() { $(".submit").on("click", function(e){ e.preventDefault(); var id = $(this).data('id'); var name = $(this).data('name'); var image = $(this).data('image'); if($('.table td#' + id).length) { //Also tried $('.table').find('td').attr('id'); but undefined is the result alert("added"); } else { $('.table').append('' + name + '<br>'); // } }) }) })(jQuery);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)