i am sorry if i have a confusing question,basically if i have a string and if a word has a hashtag it will be a hyperlink and when you click it it will redirect you to a html page showing ALL the strings that contains also the same hashtag just like the twitter.. here is my code
my script.js
var tweet = "Hello World #MerryXmas";
var splitText = tweet.split(" ");
var txt = "";
splitText.forEach(function(word)
{
var theWord = word;
if(/#/.test(theWord) == true)
{
txt += "<a href=\"hashtags.html\" target=\"_blank\"><span onclick=\"findSimilarHashtag("+ theWord +")\">"+ theWord +"</span></a>" + " ";
}
else
{
txt += theWord + " ";
}
});
function findSimilarHashtag(theWord)
{
var theWord = theWord;
var textValue = [];
for(var i in data)
{
if(data[i].lang == "en")
{
for(var j in data[i].entities.hashtags)
{
var theHashtag = data[i].entities.hashtags[j].text;
if(theWord == theHashtag)
{
textValue.push("<div id='tweetsInfo'><p>"+data[i].text+"</p></div>");
}
}
}
}
$("#theTweets").html(textValue);
}
the "theTweets" is a div id of hashtags.html that is where i want to display my values
Aucun commentaire:
Enregistrer un commentaire