Skip to content

documentation on selector #769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dwkrueger2 opened this issue Nov 26, 2017 · 2 comments
Closed

documentation on selector #769

dwkrueger2 opened this issue Nov 26, 2017 · 2 comments

Comments

@dwkrueger2
Copy link

dwkrueger2 commented Nov 26, 2017

learn.jquery.com/page/using-jquery-core/selecting-elements.md

it is unclear the relationship between the objects of jQuery and the javascript method document.getElementById()

I ran into this because I tried to change a simple attribute of a div... using the jQuery I was unsuccessful. I figured the objects might be the same or at least inherited property. So I checked and container1 is definitely different from container2...

Bottom line... the reader is likely to arrive at this page AFTER they have studied javascript and DOM. Therefore it would be nice to know the relationship between these jQuery Selectors and the getElementById() as provided by javascript.

As of writing this... I still haven't figured out why the attr setter is not working for container 1.. Is there a buffer flush or something?? Does it have to do with that dynamic vs static object concept??? I don't know it's not clear in the documentation... This page is more focused on the unique 'section' features than actually telling us what type of object it selects and returns.

/```
/ Hidden Elements initially
var form1 = $("#createSessionSignupForm").attr("display", "none");
alert("flag1");
var container1 = $("#loginBoxContainer").attr(
{
display: "none",
backgroundColor: "red"
});
alert("flag2");
var container2 = document.getElementById("loginBoxContainer").style.backgroundColor = "blue";
alert("flag3"+ (container1 === container2));

@dwkrueger2
Copy link
Author

I found a rouge article that said the .css() setter was instantaneous... and that worked... Still css properties are attributes of a tag... So the reader needs to know why this behavior is different than what was expected above.

The goal of the submission is to better the documentation... so don't bother and posting a solution unless you have a reason why the solution works and why the .attr fails to work.

@dmethvin
Copy link
Member

The page you reference seems to be pretty clear about how to select elements. The document.getElementById() method only gets elements by their ID values as the name implies, and the first example shows a jQuery equivalent. Examples further down this page and on other pages show how to manipulate collections. For specific "why doesn't this work" questions a forum like StackOverflow can probably help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants