Computing desk | ||
---|---|---|
< August 10 | << Jul | August | Sep >> | Current desk > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
I've been scanning jQuery documentation to answer a question and I cannot find anything related to this problem. Assume that I have an element in Javascript stored in a variable name "me" using something like "me = documentManager.getTheItemThatTheUserJustPicked();" So, me is an HTML element or a DOM element, basically an element. I've had a LOT of trouble explaining that me is an element like when you use "me=document.getElementById('something');" gives you an element, it is an element. Hopefully I can ask the real question and not spend hours trying to explain what "element" means. The issue: The person asking the question wants to use that element with jQuery. I know you can use selectors like $("#something") to fetch an element. The issue is that the variable "me" has the element. There is no need to hunt it down. It may not have an id. It may not have a class. So, it isn't possible to use $("#"+me.id). The person tried $(me) to select the element with the goal of doing $(me):contians("some text") to see if the element contains text. Of course, that doesn't remotely work. I believe the issue is that $(me) won't work because me is a variable containing an element and jQuery doesn't allow elements inside $(...). It needs some CSS identifiers. So, is it possible to turn the element variable "me" into a jQuery object to use jQuery functions on it? 97.82.165.112 ( talk) 13:07, 11 August 2023 (UTC)
$(me)
should definitely work - are you absolutely sure me
is really a DOM element, and not (say) an array whose only member is the element, or some fancy type of Object produced by your documentManager
?
AndrewWTaylor (
talk)
16:07, 11 August 2023 (UTC)
contains
wouldn't be the right function to use here - it's used to determine whether one DOM element contains another. If you're looking for text then you would use something like $(me).html().search("some text") >-1
. But there's no need to used jQuery for this as you can just do it by looking at me.innerHTML
. (Of course your colleague may want to use jQuery for other reasons.)
AndrewWTaylor (
talk)
16:19, 11 August 2023 (UTC)$
), the second entry in the list is jQuery( element )
, where element
is "A DOM element to wrap in a jQuery object." Your variable is that element.
AndrewWTaylor (
talk)
10:48, 12 August 2023 (UTC)This might be more of a "miscellaneous" question, but... Is it possible to wirelessly connect a Wi-Fi device to a Bluetooth device with some sort of adapter or something? -- 136.54.106.120 ( talk) 16:26, 11 August 2023 (UTC)
Computing desk | ||
---|---|---|
< August 10 | << Jul | August | Sep >> | Current desk > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
I've been scanning jQuery documentation to answer a question and I cannot find anything related to this problem. Assume that I have an element in Javascript stored in a variable name "me" using something like "me = documentManager.getTheItemThatTheUserJustPicked();" So, me is an HTML element or a DOM element, basically an element. I've had a LOT of trouble explaining that me is an element like when you use "me=document.getElementById('something');" gives you an element, it is an element. Hopefully I can ask the real question and not spend hours trying to explain what "element" means. The issue: The person asking the question wants to use that element with jQuery. I know you can use selectors like $("#something") to fetch an element. The issue is that the variable "me" has the element. There is no need to hunt it down. It may not have an id. It may not have a class. So, it isn't possible to use $("#"+me.id). The person tried $(me) to select the element with the goal of doing $(me):contians("some text") to see if the element contains text. Of course, that doesn't remotely work. I believe the issue is that $(me) won't work because me is a variable containing an element and jQuery doesn't allow elements inside $(...). It needs some CSS identifiers. So, is it possible to turn the element variable "me" into a jQuery object to use jQuery functions on it? 97.82.165.112 ( talk) 13:07, 11 August 2023 (UTC)
$(me)
should definitely work - are you absolutely sure me
is really a DOM element, and not (say) an array whose only member is the element, or some fancy type of Object produced by your documentManager
?
AndrewWTaylor (
talk)
16:07, 11 August 2023 (UTC)
contains
wouldn't be the right function to use here - it's used to determine whether one DOM element contains another. If you're looking for text then you would use something like $(me).html().search("some text") >-1
. But there's no need to used jQuery for this as you can just do it by looking at me.innerHTML
. (Of course your colleague may want to use jQuery for other reasons.)
AndrewWTaylor (
talk)
16:19, 11 August 2023 (UTC)$
), the second entry in the list is jQuery( element )
, where element
is "A DOM element to wrap in a jQuery object." Your variable is that element.
AndrewWTaylor (
talk)
10:48, 12 August 2023 (UTC)This might be more of a "miscellaneous" question, but... Is it possible to wirelessly connect a Wi-Fi device to a Bluetooth device with some sort of adapter or something? -- 136.54.106.120 ( talk) 16:26, 11 August 2023 (UTC)