Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5844845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:21:02+00:00 2026-05-22T12:21:02+00:00

learning Jquery and integrating with PHP – getting there, but have one last challenge

  • 0

learning Jquery and integrating with PHP – getting there, but have one last challenge in some code I’m working on.

I have HTML in a string, trying to pull html in tags, might be multiple elements in the HTML string, so trying to use each. My function worked fine without each, below is my each integration (returns nothing currently):

<?php 
   $info = '<li><strong><a href="http://www.mysite.com/test.html" title="Some stuff">I want this text</a></strong></li><li><strong><a href="http://www.mysite.com/test2.html" title="Some stuff">I want this text too</a></strong></li>';
   $info = json_encode($info);
?>

<script type="text/javascript">
$(document).ready(function () {

    $("a", $( < ? php echo $info; ? > )).each(

    function () {
        alert($(this).html());
    });
};

This code below does work, but only returns the first element in the HTML:

<?php
   $info = '<li><strong><a href="http://www.mysite.com/test.html" title="Some stuff">I want this text</a></strong></li>';
   $info = json_encode($info);
?>

<script type="text/javascript">
$(document).ready(function () {
    var output = $("a", $( < ? php echo $info; ? > )).html();
    var link = $("a", $( < ? php echo $info; ? > )).attr("href");
    alert(output);
    alert(link);
});
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:21:03+00:00Added an answer on May 22, 2026 at 12:21 pm

    This is a description and a working example of How to use .each() LINK

    You can try this one as a example

    $("a").each(function(index){alert($(this).html()});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to start learning jQuery, but there's so much you can do with
Hi I am still learning Jquery and have a problem accessing form elements. My
I am still learning jQuery and have come up against something I just can't
I am learning jQuery right now and am looking to validate form fields with
I'm learning jQuery and can't figure this out: Here's the HTML <a id=myid name=myid
I am just learning jquery, so this might be something easy. I am trying
I am currently learning jQuery, and I am curious about something. For functions that
I'm still learning jquery and javascript so please bear with me. I've used a
I've inherited support for a rails site with jQuery and I'm still learning jQuery.
I have a page with three HTML labels and their corresponding ASP.NET gridviews contained

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.