Forum Discussion
Deleted
Jan 29, 2018Content Query Custom Link for Both Image and Title
So I've followed the advice found here for changing the link for a Content Query Web Part to go to a custom link instead of the Sharepoint Item like it does by default. The problem is that this only works for a Content Query that is Title Only. If I include an Image and Title, then only the image points to the new link, but the title goes to the Sharepoint List Item.
Is there a way I can get both the Image and Title to point to a custom link?
The code I am using in a content editor is shown below:
<script src="https://code.jquery.com/jquery-2.1.0.min.js" type="text/javascript"></script><script type="text/javascript"> $(document).ready(function(){ for(var i = 0; i < $("#WebPartWPQ3 .item").length; i++) { // $("#WebPartWPQ3 .item")[i].href = "" // you can use this method to keep items style as a link, but cannot access the list $("#WebPartWPQ3 .item")[i].innerHTML = "<div>"+$("#WebPartWPQ3 .item")[i].innerText+"</div>"; // you can use this method to set the items sytle as text } }) </script>
- Deleted
What you could do is read the complete innerhtml and check where the image is. if it is in there.
- DeletedI checked where the image was and found that I just needed to add in the loop to also make the .link-item (not just the .item) change because that's the class the Title was in.