Web design: jQuery css() and JavaScript style: boundary testing

The tutor discusses what he noticed while experimenting with jQuery css() and JavaScript style.

JavaScript has a style function that allows you to access style attributes of an element. For example, to get an element’s color:

var e1_color=document.getElementById(“e1”).style.color;

However, as I understand, you’re not meant to harvest the entire style at once:

var e1_style=document.getElementById(“e1”).style; //not intended

Furthermore, let’s imagine you do so anyway, then try to convey that style to another element:

var e1_style=document.getElementById(“e1”).style;
document.getElementById(“e2”).style=e1_style;
//won’t work, according to my tests

Curiously, though, I’ve found that

var e1_style=document.getElementById(“e1”).style;
jQuery(“#e2”).css(e1_style);

does work on Chrome and Firefox (but not ie11).

It’s not a recommended way to change the style of an element, but it hints at how JavaScript and jQuery can have deeper communication than JavaScript with itself. It also reminds of the potential differences from browser to browser.

I’ll be talking more about JavaScript and jQuery in future posts:)

Source:

w3schools

Pollock, John. jQuery: A Beginner’s Guide. Toronto: McGraw-Hill, 2014.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Web browsers: Firefox: Show All History not quite working?

The tutor offers a way to view your history when it’s not showing.

I love Firefox; it’s the browser I use with my Linux (Ubuntu) computers.

Yesterday I clicked, at the top, History. A drop-down menu appeared, showing websites I had recently visited. “But are those all of them?” I wondered. From the drop-down, I chose the Show All History option. A window opened titled Library, but the page list was blank.

I repeated the exercise several times: after all, I thought, the Show All History option should show at least as much as the History drop-down. I even went online to research the situation: apparently, I wasn’t the only one facing it.

Eventually, I tried the search box in the Library window. By putting characters into it, I could cause pages to appear in the list. I decided the forward slash / to be best, since every page I’d been to had that in its address.

So, with Firefox, if pages aren’t showing up in the Show All History view, perhaps a solution is to type the forward slash into the search box there. I think, then, you’ll see the pages you’ve been to:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.