Explore the community Forums Lectora Lectora Questions & Answers Styling of ChangeContent Text Reply To: Styling of ChangeContent Text

#378518 Score: 0
Profile photo of Darrel Somoza
Darrel Somoza
friend finder
junior moderator
wise owl
curious george
209 pts

Jason, thank you for the kind words.

You asked. Is there a benefit to using jquery over straight javascript?

I hope you don’t mind but I’m going to append your question by adding “in Lectora” before answering it with my opinion, okay?

In my opinion, Yes, there’s a benefit. The benefit when used with Lectora lies in a couple of area’s. The first, as Math alluded to, is ease of use. Because jQuery uses the same powerful selectors as CSS it is much easier to target lectoras elements. Especially the ones that it nests, such a text.  A simple line of text is placed in a span, in a paragraph that is in a div that also contains an anchor. Some of these selectors provide the ability to directly target an element that would otherwise require iterating through a loop (very cute, Tim).

Additionally, jQuery provides methods that can accomplish difficult programmatic goals with one simple, easy to read and understand line that if written in pure JavaScript would take multiple lines of complicated, hard to read and comprehend code.

Another benefit is in how jQuery automatically handles cross-browser incompatibility issues.

Keep in mind that using jQuery does not increase the efficiency of the published output. On the contrary, because you are adding a library, it may require additional server requests which could decrease efficiency. However, published Lectora output does not follow standard web design best practices so there is no cause for concern about the difference adding the minimized jQuery library could make.

Does this mean you should always use jQuery? No. If you are doing something really simple that does not require the use of powerful CSS selectors or the built in additional functionality jQuery provides, go with pure JavaScript. You know, you can totally mix the syntax of the two together as well.

Something else to keep in mind is that its not a good idea to build a dependency on jQuery. jQuery is just a framework written in JavaScript. It is not the actual language. Only understanding how to use some cool jQuery functions, methods and plugins without understanding the JavaScript behind it is like being able to regurgitate sentences from a second language by rote. Not truly understanding what your saying will eventually land you in a situation that you can’t talk your way out of.

Of course this is just my opinion which is only 3.14 away from being an onion. I know, bad, but I saw it posted somewhere else and it made me smile.

By the way Jason, from some of the stuff I’ve seen you put together and the help you’ve provided in this forum, I think you’re doing awesome. There hasn’t been a day, nor will there ever be, that I haven’t had to turn to Stack Overflow or MDN. No matter how much I try to keep on top of this tech it stays one step ahead.

Regarding the breaking issue you described. I usually put my my header scripting at the title level just after any CSS I add. It shouldn’t matter as long as the jQuery library is loaded before you use it. Try putting your custom scripts in a ready function to ensure jQuery is loaded before your scripts are attempted:

$(document).ready(function() {  // You’re scripts });

Perhaps you’re running into a seamless play issue? Anyone else? Math, Tim?


  • This reply was modified 2 years, 10 months ago by Profile photo of Darrel Somoza Darrel Somoza. Reason: odd container added to end of my post that I removed