The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 11:01:49 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: jquery qq  (Read 2078 times)
Phaėton
Lifer
*****
Offline Offline

Posts: 555


⎝⏠⏝⏠⎠


View Profile
« on: June 23, 2010, 11:20:55 PM »

When I do the alert($("p").html());

i get 'this is a paragraph' in the alert box <p>

How do i reference the second <p>, or all <p>'s as
an array without assigning the <p id> or <p class>?
 assuming there are just two vanilla <p>'s

Code:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
  alert($("p").html());
  });
});
</script>
</head>

<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button type="button">Click me</button>
</body>

</html>
« Last Edit: June 23, 2010, 11:32:15 PM by Phaėton » Logged

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: June 23, 2010, 11:32:36 PM »

In that instance, it's only going to return/use the first p found in the bound set because the alert function is not equipped to understand it.

Although there is a much tighter way of doing this with jQuery (hint, look up iterators and a sort of foreach thang Wink ) the most immediately easy to understand is:
Code:
var pSet = $('p');
var max = pSet.length;
for (var i=0; i<max; i++)
alert(pSet[i].html());

... although it's late and I'm pretty certain I've done that wrong
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Phaėton
Lifer
*****
Offline Offline

Posts: 555


⎝⏠⏝⏠⎠


View Profile
« Reply #2 on: June 23, 2010, 11:39:30 PM »

awesome... thanks...

its later for me!!! wake up, america!

Cheesy

do google spiders execute java code or
could you put stuff in a div like this for
the spider:

<p>penis pills, sex scandal, oil spill, viagra</p>


and then load some .js from a server somewhere like:

<script type="text/javascript" src="switcharoo.js"></script>


that had a function in it to replace it with your
latest scam like:

$(selector).append(secretcontentooglegaywillneverknow)




Logged

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: June 23, 2010, 11:46:18 PM »

Yes they can execute code, however the consistency and impact of that has never been clearly proven. They *absolutely* do some things with code, however some have postulated that they only look for certain things and infer from the code, rather than actually run it (which would be rather smart and keep their spiders out of crappy code loops).

What you're talking about is client side cloaking. It can be done, but real care must be taken. I do some of this still today, but I am *extremely* careful and also very good at it. There are some techniques that the clever person would say, "c'mon man, that's a straight up cloak" but I can argue plausible deniability and strong reason for the mechanics in the code. In fact, a Google analyzer might look at my code and think it was the height of contemporary multi-browser, multi-modality HTML. F'reals  Mobster
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Phaėton
Lifer
*****
Offline Offline

Posts: 555


⎝⏠⏝⏠⎠


View Profile
« Reply #4 on: June 23, 2010, 11:53:01 PM »

ahh... just googled it,
 i see... mr wikipedia.. Wink 
Logged

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡
kurdt
Lifer
*****
Offline Offline

Posts: 1153


paha arkkitehti


View Profile
« Reply #5 on: June 23, 2010, 11:55:56 PM »

Perk is right about Google analyzing javascript. I remember reading many years back that Google either patented or somebody from Google said publicly that they have some sort of technology that renders the page. They didn't specify much but it's very likely that they are rendering pages in some cases. It could be useful in detecting content and navigation areas. Also if they render pages, they might be able to detect client-side cloaking just by detecting weird shit going on compared to what their code analyzer thinks. Of course you won't get penalized until manual review is done but you probably won't be enjoying top rankings until manual review is done.
Logged

I met god and he had nothing to say to me.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!