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 7850967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:02:59+00:00 2026-06-02T19:02:59+00:00

Hi I have the following code in a javaScript file called songs: var marchMD

  • 0

Hi I have the following code in a javaScript file called songs:

var marchMD = new Array();
marchMD[0] = ["Save the Best for Last - Vanessa Williams"];
marchMD[1] = ["Informer - Snow"];
marchMD[2] = ["The Sign - Ace of Base"];    

for (var i=0;i<marchMD.length; i++) {
    songList = songList + '<p><a href="#" id="songtext">' + marchMD[i] + '</a></p>';
}
$('#songs').html(songList);

Once this has been loaded, the follow javaScript in the file youtube reacts with the code above:

$(document).ready(function() {

    $('#songs p').click(function(e) {

        var $el = $(e.currentTarget);
        var search = $el.html();
        //alert(search);
        //return;

        var keyword = encodeURIComponent(search);
        var yt_url = 'http://gdata.youtube.com/feeds/api/videos?q=' + keyword + '&format=5&max-results=1&v=2&alt=jsonc';

        $.ajax({
            type:"GET",
            url: yt_url,
            dataType: "jsonp",
            success: function(response) {
                if(response.data.items) {
                    $.each(response.data.items, function(i, data) {
                        var video_id = data.id;
                        var video_frame = "<iframe width='420' height='315' src='http://www.youtube.com/embed/" + video_id + "' frameborder='0' type='text/html'></iframe>";
                        $("#ytVid").html(video_frame);
                    });
                } else {
                    $("#ytVid").hmtl("<div id='no'> No Video</div>");
                }
            }
        });
    });
});

The alert that I have in the code above was a test to see if it would return anything and it doesn’t. However, if I remove the href html tag from the code this works. The reason I have it is so when someone clicks one of the songs, it takes them to the top of the page to view that song in youtube.

Thanks

  • 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-06-02T19:03:00+00:00Added an answer on June 2, 2026 at 7:03 pm

    If you know that the element that contains your link will only ever contain your link, you could use text() to strip out the HTML formatting, like this:

     var search = $el.text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in an external JavaScript file that is called within
I have the following JavaScript code: oCoord = {x: null, y: null}; var aStack
I have written the following Javascript code : var outerFrame = document.getElementById(myframe); var outerDoc
I have a file called: file.php contained in this file is the following code:
I have the following code: http://www.nomorepasting.com/getpaste.php?pasteid=22615 Which is called by the javascript mentioned in
I have the following code below in a javascript file and need to have
I have the following code in JavaScript and jQuery: $(<li />) .html('Some HTML') I
I have the following Javascript code. When the page is loaded it is scrolled
I have the following JavaScript code which I like to convert to jQuery but
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);

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.