Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
HTML Pages with CSS and JavaScript
Create a Table as a jQuery plugin
samuel marin
Greenhorn
Posts: 24
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I would like to know how can I create a HTML table in JQueryP code dinamicaly.
I would like to create a simple table like:
<table bgcolor=white width="245">
<tr>
<td>
<font color=darkblue size=3>Category 1</font>
<br>
<font color=#1dc4ff size=2><a href="">Element 1</a></font>
<br>
<font color=#1dc4ff size=2><a href="">Element 2</a></font>
</td>
</tr>
</table>
In something that I can code in my .jsp file. Something like:
(function( $ ) {
$.fn.MyTable = function(options) {
});
};
Thank you so much
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
JSP
or jQuery? You ask about JSP and then show code that creates a jQuery plugin.
Also, attributes such as
bgcolor
and tags such as
<font>
are deprecated and should not be used.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
samuel marin
Greenhorn
Posts: 24
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sorry, I was refering to JQuery.
Thanks
I'm trying to be able to create a Table dynamically since I'm going to have it in many different sites I don't want to change the table in all the sites each time I need to modify the table.
I tried the following and I don't know why is not working:
$.fn.MyTable = function(options) { return this.each(function() { var table = $('<table/>'); for (var i=0; i<1500; i++) { var tds = ''; tds += '<td>one</td>'; tds += '<td>two</td>'; tds += '<td>three</td>'; tds += '<td>eight</td>'; table.append('<tr>'+tds+'</tr>'); } $('#output').append(table); }); };
Calling it:
<script>$(function() {$('#sidebar-lef').MyTable();});</script>
Thanks again
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Please read
ItDoesntWorkIsUseless
and tell us in detail what's not working.
Also, have you launched the JavaScript debugger and tried stepping through the code to see where it's going awry?
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What is the purpose of calling the plugin on "#sidebar-lef" if you've hard-coded the table parent as "#output"?
Also, the table element is not self-closing, specify one of
$('<table>')
or
$('<table></table>')
.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
samuel marin
Greenhorn
Posts: 24
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Here is the jsfiddle of what I'm trying
http://jsfiddle.net/samuvk/fbvXn/
Thanks
samuel marin
Greenhorn
Posts: 24
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Solved.
Thanks
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Automatic flushing of response
Take the quiz: Which sci-fi crew would you fit best in?
Struts1 to Struts2 Migration
SqlException accured at processing Jsp
INCLUDES.DBconnection error
More...