|
Style by element class, content by element id
|
|
20th December, 13:55
Post: #1
|
|||
|
|||
|
Style by element class, content by element id
Hey, I just wanted to post the method I used to set default styles for a group of tips using their class, but set content individually using their ids.
I had a look around the forums for a better method but couldn't find exactly what I was looking for. If someone knows a better way, please advise. I was basically not happy with having to repeat the settings for style and behavior for each element to also set their content. I wanted just one declaration for that stuff so I could change it easily and leave the content as separate. In the doc head, I use an associative array containing element IDs and their content, then a for each loop selecting elements by class (.qtip) and applying generic styles and the specific content where the id matches: JS Code
My tooltip elements look like this: JS Code
Hope it helps. |
|||
|
19th February, 01:49
Post: #2
|
|||
|
|||
|
RE: Style by element class, content by element id
Just noticed an error - don't know why it put strong tags after the o in onclick? I can't get it to show the code without them though.
(20th December 13:55)teeks Wrote: Each link should be JS Code
The onclick was just to stop it from appending the # to the URL for testing with internal links. |
|||
|
24th February, 22:04
(This post was last modified: 24th February 22:05 by speshulk926.)
Post: #3
|
|||
|
|||
|
RE: Style by element class, content by element id
You are THE MAN! Your example was *exactly* what I was wanting to do. I really appreciate it, because I was getting frustrated on how to achieve this!! YAY!
|
|||
|
26th February, 01:18
Post: #4
|
|||
|
|||
RE: Style by element class, content by element id
(24th February 22:04)speshulk926 Wrote: You are THE MAN! Your example was *exactly* what I was wanting to do. I really appreciate it, because I was getting frustrated on how to achieve this!! YAY!Cheers. I feel warm and fuzzy now. This is the first time I've contributed back to anything, usually I'm under too much pressure to move on to the next job. I'll try and continue this way though, its more rewarding.
|
|||
|
26th February, 06:39
Post: #5
|
|||
|
|||
|
RE: Style by element class, content by element id
The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML:
As a style sheet selector (when an author wishes to assign style information to a set of elements). For general purpose processing by user agents. |
|||
|
27th February, 03:44
Post: #6
|
|||
|
|||
RE: Style by element class, content by element id
(26th February 06:39)james121 Wrote: The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML: I thought this post was weird, it has nothing to do with the thread and smells like something a bot would say, so I googled it and its copied exactly from http://www.w3.org documentation. Report spam? |
|||
|
27th February, 22:07
Post: #7
|
|||
|
|||
RE: Style by element class, content by element id
(27th February 03:44)teeks Wrote: I thought this post was weird, it has nothing to do with the thread and smells like something a bot would say, so I googled it and its copied exactly from http://www.w3.org documentation. Report spam? Thanks teeks for the heads up, does seem very bot-like. I've warned him and sent a PM. Craig Thompson Web Developer / Designer Craigsworks http://www.craigsworks.com |
|||
|
15th March, 22:49
Post: #8
|
|||
|
|||
|
RE: Style by element class, content by element id
It did n,t work for me:
here is what I did: JS Code
the tool tips : JS Code
thanks for your help[/quote][/php] |
|||
|
17th March, 00:23
Post: #9
|
|||
|
|||
| RE: Style by element class, content by element id | |||
|
24th March, 09:06
Post: #10
|
|||
|
|||
|
RE: Style by element class, content by element id
The below code does not work at all... can someone tell me how to get it working?
(15th March 22:49)insideout Wrote: It did n,t work for me:[/php] [/quote] |
|||
|
24th March, 12:46
Post: #11
|
|||
|
|||
RE: Style by element class, content by element id
(24th March 09:06)junkiexl09 Wrote: The below code does not work at all... can someone tell me how to get it working?[/quote] Well seeing as you quoted the code that insideout already said didn't work, that's not surprising. You need to post what kind of error you're having or your exact code or a URL where people can see what's happening otherwise its a little hard to debug based on: it doesn't work. |
|||
|
Yesterday, 05:30
Post: #12
|
|||
|
|||
|
RE: Style by element class, content by element id
Hello this method works for me perfectly with:
JS Code
My issue now is that the qtip opens with the correct data but like a flying box randomly from any position in direction to the supposed postion. If I just replace the dynamic data for static string this doen't happens. Any suggestion or issue for position / dynamic data using this type of method?
|
|||
|
Yesterday, 07:03
Post: #13
|
|||
|
|||
RE: Style by element class, content by element id
(Yesterday 05:30)alfonsomr Wrote: Hello this method works for me perfectly with: I had the same problem using google maps in a tip, probably just because it has to figure out redering position and size on the fly. Maybe having default static content, then replacing it dynamically as required, would at least give it something to render?? Static content could be "loading..." or something, because people won't see it anyway right? |
|||
|
Yesterday, 13:36
Post: #14
|
|||
|
|||
|
RE: Style by element class, content by element id
Thank you Teeks for the suggestion. I did that, the static text ("Loading...") appear correctly but when it is replaced by the dynamic data, the position of the tip is affected because the dynamic text is longer... the height of the box increased.
|
|||
|
15th November, 21:35
(This post was last modified: 15th November 21:36 by garbledygook.)
Post: #15
|
|||
|
|||
RE: Style by element class, content by element id
(26th February 06:39)james121 Wrote: The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML: I've also used solutions that simply use the each() function, and then just do a switch on the attr('id') for the current element matching my each loop. This comes in handy if you are using a lot of variable text qualifiers on your elements for descriptive purposes. Then based on that you can change default values for variables, then simply call a function like AddQtip passing in the appropriate changes and be done with it. If you wanted, I'm guessing you could make some kind of struct to use, etc. |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)

Search
Member List
Calendar
Help




