2012-11-26 58 views
0

我正在制作新闻应用,并且使用名为zRSSFeed的jQuery插件。该插件提供了一项功能,可通过从下拉列表中选择新闻来源来更改显示的RSS提要,该功能将更改显示在结果Div中的提要(请参阅示例here)。通过从链接列表中选择订阅源动态加载订阅源

的源代码:

<script src="http://jquery/1.7.1/jquery.min.js" type="text/javascript"></script> 
<script src="jquery.zrssfeed.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
    setRSSFeed('#menu'); 
    $('#menu').change(function() { 
     setRSSFeed(this) 
    }); 
    function setRSSFeed(obj) { 
     var feedurl = $('option:selected', obj).val(); 
     if (feedurl) { 
     $('#result').rssfeed(feedurl); 
     } 
    } 
    }); 
</script> 
<select id="menu">  
    <optionvalue="http://feeds.reuters.com/reuters/oddlyEnoughNews">News</option> 
    <option value="http://feeds.bbc.co.uk/iplayer/highlights/tv/list">BBC </option> 
    <option value="http://rss.cnn.com/rss/edition.rss">CNN News</option> 
</select> 
<div id="result"></div> 

我的问题是,而不是改变从下拉列表中选择一个newSource的显示的料,我很想通过选择与指定的新源链接(HREF)来改变它们。

回答

0

不使用该

<select id="menu">  
    <optionvalue="http://feeds.reuters.com/reuters/oddlyEnoughNews">News</option> 
    <option value="http://feeds.bbc.co.uk/iplayer/highlights/tv/list">BBC </option> 
    <option value="http://rss.cnn.com/rss/edition.rss">CNN News</option> 
</select> 

。使用本

<script type="text/javascript"> 
    $(document).ready(function() { 
    //setting default feed 
    setRSSFeed('http://feeds.reuters.com/reuters/oddlyEnoughNews'); 
    }); 
    function setRSSFeed(feedurl) { 
     if (feedurl) { 
      $('#result').rssfeed(feedurl); 
       } 
       } 
      }); 
</script> 

    <a href="#" onclick="setRSSFeed('http://feeds.reuters.com/reuters/oddlyEnoughNews');">News</a> 
    <a href="#" onclick="setRSSFeed('http://feeds.bbc.co.uk/iplayer/highlights/tv/list');">BBC</a> 
    <a href="#" onclick="setRSSFeed('http://rss.cnn.com/rss/edition.rss');">CNN News</a>  
+0

其不工作...我是新手,请写出来的一切显然谢谢! –

+0

你可以请现在检查我已经更新了答案 –

+0

谢谢sheldon它的工作! –